- Home /
Question by
Gamingdrake · Mar 09, 2015 at 04:28 AM ·
editorinputbug-perhapsscene view
Unity capturing events in editor and not letting go
I have been programming in the Unity Editor for a long time now. Occasionally, when using my scripts, the editor will grab hold of the current mouse state (orbit, hand tool, rotate tool) and not let go, essentially locking all input into the scene. The only way I can get it to come back is to restart Unity, reopen the scene, or by clicking play (which takes awhile). Anyone have any ideas. Below is my code.
void SceneGUI(SceneView sceneView)
{
Event current = Event.current;
int ID = GUIUtility.GetControlID(HASH_CODE, FocusType.Passive);
EventType type = current.GetTypeForControl(ID);
bool used = false;
if (isEditing)
{
#region MouseInput
if (type == EventType.MouseUp && current.button == 0 && !current.alt)
{
DoClickEvent(current);
used = true;
}
#endregion
//this happens when the world is focused in the scene
#region KeyboardInput
if (current.type == EventType.KeyDown && current.keyCode == KeyCode.PageUp)
{
//TODO:
used = true;
}
else if (current.type == EventType.KeyDown && current.keyCode == KeyCode.PageDown)
{
//TODO:
used = true;
}
if ((type == EventType.Layout || used) && !current.alt)
{
current.Use();
HandleUtility.AddDefaultControl(ID);
}
#endregion
}
}
Comment