- Home /
Use up a scene selection in the editor.
I am working on a custom editor that allows the user to connect one object to another. It ads the selected object to a variable and does some calculation based on the selection.
What i want to do is have the user push a button in the inspector, then a gizmo will be drawn on each of the selectable objects. The user clicks one of the objects to connect to.
The problem is that whenever another object is click the selection changes and the custom inspector is no longer used. So what i want to do is somehow use up the click when a certain type of is clicked, after the "Connect to.." button in the custom inspector has been clicked.
Is there any way to achieve this?
I have tried using Event.current.Use() but it doesn't seem to do the trick.
Answer by Immanuel-Scholz · Jun 25, 2013 at 11:29 AM
Look into HandleUtility.AddDefaultControl
which is the control that gets "selected if nothing is selected". (kindof).
Basically, to prevent deselection, add this to your OnSceneGUI
if (Event.current.type == EventType.Layout)
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
Your answer
Follow this Question
Related Questions
Preventing editor deselect on MacOS 1 Answer
Left Click Up Event in Editor 4 Answers
Spline Editor: Maintain object selection and object attachments 0 Answers
How does Unity handle GameObject selection in the Scene View? 1 Answer
OnGUI Event 0 Answers