Editor Scripting - Forcing SceneView to be Focused?

Hey Guys,

Is there any way to make an EditorWindow force keyboard/mouse focus onto the Scene View? I have some OnSceneGUI code that’s not being run, because when I click a button in the EditorWindow, it forces focus to that window.

What I’d like, is for whenever you press a window button, for the window to lose focus and bring the SceneView to the forefront, but I can’t seem to find any documentation on how to do that.

Any tips/pointers would be greatly appreciated. Thanks!

mmm. You can do a script where uses Input.GetKey(“KEY”) , and move camera like in normal game mode. But try to put in the top of the script:

@script ExecuteInEditMode()

Thanks for the reply, but I’m not quite sure I understand. I’m not trying to move the camera, simply change the focused editor window.

Also, unless I’m wrong, I dont’ think Input.GetKey works very well in editor scripting, and the use of Events is used it its place. (Which is actually part of the reason I’m trying to do this - my Events won’t capture if the SceneView isn’t the focused window :P)

Sorry I have no clue! :stuck_out_tongue:

This problem is in the editor, right? Before the game is being run?

Yes, Editor Scripting. I’m making a custom tool in the editor - but my OnSceneGUI block isn’t being run properly when focus is on the EditorWindow, so I’d like to find a way to force focus on the Scene View.

Have you tried this:

http://unity3d.com/support/documentation/ScriptReference/EditorWindow.Focus.html

Seems somebody else was having the same problem - and found a solution :slight_smile:

Thanks for all the input guys!