- Home /
Editor: calling event.use() prevents gizmos from being drawn
If I do something like this....
[CustomEditor(typeof(mycomponent)]
public class MyEditorClass: Editor
{
void OnSceneGUI()
{
Event e = Event.current;
//if the shift key is being held down
if (e.shift)
{
//do stuff
e.use()
}
}
}
ie. Have a custom editor class that does something when shift is held down. All the time shift is held down the gizmos for everything are not drawn. I guess this is because I am using all the events before they are drawn. Is there some way to tell the gizmos to draw anyway?
Note: I believe I need to use the event every OnSceneGUI(), otherwise the stuff I'm doing in it does not get updated, for instance when I move the mouse.
Answer by deltron1830 · Aug 24, 2014 at 01:01 AM
Ok, I solved this just after posting this question!!
If I only use the event in the case the event type being something I care about (like the mouse moving of being clicked then its ok) :)
[CustomEditor(typeof(mycomponent)]
public class yourEditorClass: Editor
{
void OnSceneGUI()
{
Event e = Event.current;
if (e.shift)
{
switch (e.type)
{
case EventType.mouseDown:
Debug.Log("mousedown");
e.Use();
break;
case EventType.mouseUp:
Debug.Log("mouseup");
e.Use();
break;
case EventType.MouseMove:
//Do my moving stuff here
Debug.Log("move");
e.Use();
break;
case EventType.layout:
HandleUtility.AddDefaultControl(cID);
break;
}
}
}
Your answer
Follow this Question
Related Questions
How to disable the default transform gizmo in editor? 1 Answer
Handles.matrix seems strange? 2 Answers
Mouse click in edit mode. ✱✺✸❁ 1 Answer
Editor OnSceneGUI - Capture click on Gizmo 0 Answers
Left Click Up Event in Editor 4 Answers