- Home /
Question by
crotchfruit · Apr 06, 2011 at 06:15 PM ·
mouseonsceneguideselect
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?
Comment
Answer by hardwire · Jun 14, 2011 at 12:05 PM
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()
Thanks! I had this problem and this was a perfect solution.