private static void RunTest(TestArchetypesRun run) { var undoRedo = new UndoRedoService(100); // We don't have easy access to the context and the graphes, let's use dynamic for simplicity dynamic dynamicRun = run; var context = dynamicRun.Context; ((AssetPropertyGraph)context.BaseGraph).Changed += new AssetSlimContainer(undoRedo, context.BaseGraph).AssetPropertyChanged; ((AssetPropertyGraph)context.DerivedGraph).Changed += new AssetSlimContainer(undoRedo, context.DerivedGraph).AssetPropertyChanged; ((AssetPropertyGraph)context.BaseGraph).ItemChanged += new AssetSlimContainer(undoRedo, context.BaseGraph).AssetPropertyChanged; ((AssetPropertyGraph)context.DerivedGraph).ItemChanged += new AssetSlimContainer(undoRedo, context.DerivedGraph).AssetPropertyChanged; using (undoRedo.CreateTransaction()) { run.FirstChange(); } using (undoRedo.CreateTransaction()) { run.SecondChange(); } run.SecondChangeCheck(); undoRedo.Undo(); run.FirstChangeCheck(); undoRedo.Undo(); run.InitialCheck(); undoRedo.Redo(); run.FirstChangeCheck(); undoRedo.Redo(); run.SecondChangeCheck(); }
private void Update() { // 按键 S 表示 Record (记录) 步骤操作; if (Input.GetKeyDown(KeyCode.S)) { UndoRedoService.Record(); UnityTool.Log("Record"); } // 按键 U 表示 Undo (撤销) 操作; if (Input.GetKeyDown(KeyCode.U)) { UndoRedoService.Undo(); UnityTool.Log("Undo"); } // 按键 R 表示 Redo (重做) 操作; if (Input.GetKeyDown(KeyCode.R)) { UndoRedoService.Redo(); UnityTool.Log("Redo"); } }
public override void Execute(object parameter) { if (_isUndo) { _undoRedoService.Undo(); } else { _undoRedoService.Redo(); } }
public void BasicPropertyChangeIsRecorded() { _modelRecorder.Record(_undoRedoService, _recordedModel); var initialValue = _recordedModel.IsTrue; Assert.IsFalse(_undoRedoService.CanUndo); Assert.IsFalse(_undoRedoService.CanRedo); _recordedModel.IsTrue = !initialValue; Assert.IsTrue(_undoRedoService.CanUndo); Assert.IsFalse(_undoRedoService.CanRedo); _undoRedoService.Undo(); Assert.AreEqual(_recordedModel.IsTrue, initialValue); Assert.IsFalse(_undoRedoService.CanUndo); Assert.IsTrue(_undoRedoService.CanRedo); _undoRedoService.Redo(); Assert.AreEqual(_recordedModel.IsTrue, !initialValue); Assert.IsTrue(_undoRedoService.CanUndo); Assert.IsFalse(_undoRedoService.CanRedo); }