private static void CheckMouseControls(Event e) { if (!e.isMouse) { return; } int controlID = GUIUtility.GetControlID(ControlIDHashCode, FocusType.Passive); switch (e.GetTypeForControl(controlID)) { case EventType.MouseDown: if (e.button == 0) { oldID = GUIUtility.hotControl; GUIUtility.hotControl = controlID; mouseDown = true; e.Use(); } break; case EventType.MouseUp: if (mouseDown && e.button == 0) { if (Selection.activeGameObject != null) { SelectObject(e); GUIUtility.hotControl = oldID; } else { if (!MapEditorControl.Build(e)) { SelectObject(e); } GUIUtility.hotControl = 0; } mouseDown = false; e.Use(); } break; case EventType.MouseDrag: if (mouseDown) { GUIUtility.hotControl = oldID; oldID = 0; e.Use(); } break; } PreviewObject.ShowPreview = GUIUtility.hotControl == 0 || !mouseDown; }
private static void CheckKeyControls(Event e) { if (e.isKey) { if (!keyDown && e.type == EventType.KeyDown) { keyDown = true; if (RotateKeys(e)) { e.Use(); } else { switch (e.character) { case 'a': MapEditorControl.Build(e); e.Use(); break; case 'd': foreach (GameObject obj in Selection.gameObjects) { Undo.DestroyObjectImmediate(obj); } e.Use(); break; default: keyDown = false; break; } } } else if (e.type == EventType.KeyUp) { keyDown = false; } } }