/// <summary> /// This method handles the shortcut keys which are related to the editor object selection system. /// </summary> private void HandleEditorObjectSelectionKeys() { EditorObjectSelection objectSelection = EditorObjectSelection.Instance; // If any of the CTRL/CMD keys are pressed, we will let the user add objects to the selection. Otherwise, // adding to the current selection will be disabled. if (InputHelper.IsAnyCtrlOrCommandKeyPressed()) { objectSelection.AppendOrDeselectOnClick = true; } else { objectSelection.AppendOrDeselectOnClick = false; } // If any of the SHIFT keys are pressed, we will let the user deselect multiple object at once using the // object selection shape. Otherwise, multiple deselection will be disabled. if (InputHelper.IsAnyShiftKeyPressed()) { objectSelection.MultiDeselect = true; } else { objectSelection.MultiDeselect = false; } if (Input.GetKeyDown(KeyCode.D) && !Input.GetMouseButton((int)MouseButton.Right)) { if ((Application.isEditor && Input.GetKey(KeyCode.LeftShift)) || (!Application.isEditor && Input.GetKey(KeyCode.LeftControl))) { var action = new ObjectDuplicationAction(new List <GameObject>(EditorObjectSelection.Instance.SelectedGameObjects)); action.Execute(); } } }
private void Update() { if (!Application.isEditor) { if (Input.GetKeyDown(KeyCode.Z) && InputHelper.IsAnyCtrlOrCommandKeyPressed()) { Undo(); } else if (Input.GetKeyDown(KeyCode.Y) && InputHelper.IsAnyCtrlOrCommandKeyPressed()) { Redo(); } } else { if (Input.GetKeyDown(KeyCode.Z) && InputHelper.IsAnyCtrlOrCommandKeyPressed() && InputHelper.IsAnyShiftKeyPressed()) { Undo(); } else if (Input.GetKeyDown(KeyCode.Y) && InputHelper.IsAnyCtrlOrCommandKeyPressed() && InputHelper.IsAnyShiftKeyPressed()) { Redo(); } } }
/// <summary> /// This method handles the shortcut keys which are related to the undo/redo system. /// </summary> private void HandleEditorUndoRedoSystemKeys() { EditorUndoRedoSystem undoRedoSystem = EditorUndoRedoSystem.Instance; // Note: When the application is not running in editor mode, we will use the // standard shortcut keys for Undo/Redo (CTRL/CMD + Z, CTRL/CMD + Y). // Otherwise, we will add the SHIFT key into the mix in order to stop // the Unity editor from invoking its own Undo/Redo system. if (!Application.isEditor) { if (Input.GetKeyDown(KeyCode.Z) && InputHelper.IsAnyCtrlOrCommandKeyPressed()) { undoRedoSystem.Undo(); } else if (Input.GetKeyDown(KeyCode.Y) && InputHelper.IsAnyCtrlOrCommandKeyPressed()) { undoRedoSystem.Redo(); } } else { if (Input.GetKeyDown(KeyCode.Z) && InputHelper.IsAnyCtrlOrCommandKeyPressed() && InputHelper.IsAnyShiftKeyPressed()) { undoRedoSystem.Undo(); } else if (Input.GetKeyDown(KeyCode.Y) && InputHelper.IsAnyCtrlOrCommandKeyPressed() && InputHelper.IsAnyShiftKeyPressed()) { undoRedoSystem.Redo(); } } }