Exemplo n.º 1
0
        private IEnumerator UndoRedoDeleteObject()
        {
            ILevelEditorObject newCube = objectManager.CreateObject("cube");
            uint instanceId            = newCube.InstanceID;

            yield return(WaitFrames(1));

            // Make sure the object exists.
            Assert.IsTrue(LevelEditorWorld.TryGetObject(instanceId, out _));
            objectManager.DeleteObject(newCube);

            yield return(WaitFrames(1));

            // Make sure the object doesn't exist.
            Assert.IsFalse(LevelEditorWorld.TryGetObject(instanceId, out _));

            undo.Undo();

            yield return(WaitFrames(1));

            // Make sure the object exists.
            Assert.IsTrue(LevelEditorWorld.TryGetObject(instanceId, out _));

            undo.Redo();

            yield return(WaitFrames(1));

            // Make sure the object doesn't exist.
            Assert.IsFalse(LevelEditorWorld.TryGetObject(instanceId, out _));
        }
        public void Redo(ILevelEditorUndo undo)
        {
            if (current == null)
            {
                undo.LevelEditor.Selection.SetSelection(null, false);
                return;
            }

            if (LevelEditorWorld.TryGetObject(current.InstanceID, out ILevelEditorObject currentObj))
            {
                undo.LevelEditor.Selection.SetSelection(currentObj, false);
            }
        }
        public void Undo(ILevelEditorUndo undo)
        {
            if (previous == null)
            {
                undo.LevelEditor.Selection.SetSelection(null, false);
                return;
            }

            if (LevelEditorWorld.TryGetObject(previous.InstanceID, out ILevelEditorObject previousObj))
            {
                undo.LevelEditor.Selection.SetSelection(previousObj, false);
            }
        }