Search Unity

Question Possible to focus the editor Game window on Play with Code?

Discussion in 'Editor & General Support' started by zedz, May 29, 2023.

  1. zedz

    zedz

    Joined:
    Aug 31, 2013
    Posts:
    250
    A pretty minor thing, so not important

    But I want to simulate clicking on the window when I press play in the editor
    because at the moment
    Mouse.current.position.ReadValue() returns wrong values until I first click on the window

    I thought
    UnityEditor.EditorWindow.focusedWindow.Focus();
    would do it but No.

    BTW I have GameWindow > Play Focused selected from the dropdown menu.

    Like I said minor, just a minor anoyance. Cheers
     
    Last edited: May 29, 2023
  2. zedz

    zedz

    Joined:
    Aug 31, 2013
    Posts:
    250
    Ha, Googling for an answer to this and went oh that looks promising, someone has asked it. Go to the link
    Oh it was me that asked it 10 months ago. Any answers btw?

    Looking at what I wrote above doesn't make sense
    focusedWindow.Focus() <- I want to focus the already focused window :D
     
    Last edited: Mar 25, 2024