Esempio n. 1
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        public void Execute()
        {
            if (_gameObjects.Count != 0)
            {
                // Take a snapshot to allow for undo
                _preChangeMaskSnapshot = new ObjectSelectionMaskSnapshot();
                _preChangeMaskSnapshot.TakeSnapshot();

                // Assign the objects to the selection mask.
                // Note: We will also perform a snapshot of the current object selection just in case
                //       the object selection changes after the objects are assigned to the mask.
                _preChangeSelectionSnapshot = new ObjectSelectionSnapshot();
                _preChangeSelectionSnapshot.TakeSnapshot();
                EditorObjectSelection editorObjectSelection = EditorObjectSelection.Instance;
                _selectionWasChanged = editorObjectSelection.AddGameObjectCollectionToSelectionMask(_gameObjects);

                // If the selection was changed, we will perform a snapshot post change to make sure that we
                // can undo and redo the action accordingly. For example, if assigning the objects to the mask
                // caused a selection change, when the operation is undone, we want to restore both the mask
                // and the state that the selection was in before the mask was updated.
                if (_selectionWasChanged)
                {
                    _postChangeSelectionSnapshot = new ObjectSelectionSnapshot();
                    _postChangeSelectionSnapshot.TakeSnapshot();
                }

                // Take a snapshot to allow for redo
                _postChangeMaskSnapshot = new ObjectSelectionMaskSnapshot();
                _postChangeMaskSnapshot.TakeSnapshot();

                ObjectsAddedToSelectionMaskMessage.SendToInterestedListeners(_gameObjects);
                EditorUndoRedoSystem.Instance.RegisterAction(this);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        public void Execute()
        {
            if (_gameObjects.Count != 0)
            {
                // Take a snapshot to allow for undo
                _preChangeMaskSnapshot = new ObjectSelectionMaskSnapshot();
                _preChangeMaskSnapshot.TakeSnapshot();

                // Remove the objects from the selection mask.
                EditorObjectSelection editorObjectSelection = EditorObjectSelection.Instance;
                editorObjectSelection.RemoveGameObjectCollectionFromSelectionMask(_gameObjects);

                // Take a snapshot to allow for redo
                _postChangeMaskSnapshot = new ObjectSelectionMaskSnapshot();
                _postChangeMaskSnapshot.TakeSnapshot();

                ObjectsRemovedFromSelectionMaskMessage.SendToInterestedListeners(_gameObjects);
                EditorUndoRedoSystem.Instance.RegisterAction(this);
            }
        }