How do I prevent Unity from deselecting the current object when I click in the SceneView?

I'm trying to do drawing in the SceneView window, but Unity keeps deselecting the object with my drawing script when I click.

From the docs, it looked like calling Event.Current.Use in OnSceneGUI was the way to go, but it doesn't seem to be working.

Any ideas?

1 Answer

1

If you add your own control Unity won’t use the “selector” control by default and thus clicking in the scene won’t deselect your object. To do so call

HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

in OnSceneGUI()

Works perfectly! Thank you