How to stop inspector losing focus when clicking in scene view?

Going to bring this thread back as I found some stuff out that I think would be helpful, that I learnt while working on this: Editor scene objects pipette - #19 by spiney199

One, you can prevent objects being selected in the scene if you have this running in any OnSceneGUI code:

private void OnSceneGUI()
{
    int id = GUIUtility.GetControlID(FocusType.Passive);
    HandleUtility.AddDefaultControl(id);
}

And two, you can still ‘pick’ game objects using a number of methods available in the HandleUtility class: Unity - Scripting API: HandleUtility

In my linked example, I registered a callback to the SceneView.rootVisualElement’s and used that to determine where the click happened.

2 Likes