public sealed class CommandStackAn undo history: what has been done, what has been undone, and where "saved" was.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
There is one of these per document and one for the project. A document's stack holds the edits made inside it; the project's global stack holds the operations that are not inside any one document — renaming an asset, moving a file, reorganising a folder — because putting a cross-document operation on one of the documents it happened to touch means undoing it depends on which tab has focus.
The interaction between the two is one rule: when a command touches a document that is not the one its stack belongs to, that document's redo stack is discarded and it is marked modified. Its redo entries were recorded against a world that has since moved, and replaying them would write stale values back. Discarding is the only answer that cannot silently corrupt; the alternative — rewriting the affected entries — needs every command type to know how to be rebased, which is a research project.
Everything a menu binds to is a signal. "Undo" is enabled from CanUndo and labelled from UndoName, and a title bar's asterisk comes from IsDirty, with no change notifications to wire up and nothing to forget to raise.
Fields and properties (12)
public const int DefaultCapacityHow many entries a stack keeps before the oldest starts falling off.
public EditorContext ContextWhat the commands on this stack are handed.
public bool IsGlobalWhether this is the project's stack rather than a document's.
public IReadOnlySignal<bool> CanUndoWhether Undo would do something.
public IReadOnlySignal<bool> CanRedoWhether Redo would do something.
public IReadOnlySignal<bool> IsDirtyWhether anything has changed since the last MarkClean.
public IReadOnlySignal<string?> UndoNameWhat Undo would undo, or if nothing.
public IReadOnlySignal<string?> RedoNameWhat Redo would redo, or if nothing.
public IReadOnlySignal<int> DepthHow many entries can be undone.
public IReadOnlyList<IEditorCommand> HistoryThe undo entries, oldest first.
public bool InTransactionWhether a transaction is open.
public int CapacityHow many entries this stack keeps, or zero for no limit.
Methods (8)
public void Execute(IEditorCommand command)Runs a command and records it.
public bool Undo()Undoes the newest entry.
public bool Redo()Redoes the newest undone entry.
public void Seal()Closes the newest entry to merging, so the next command starts a fresh undo step.
public void MarkClean()Records that this is the state on disk.
public void ClearRedo()Throws away everything that could be redone.
public void Clear()Throws away the whole history.
public CommandTransaction BeginTransaction(string name)Collects everything executed until it closes into one undo entry.
Used by (88, showing 40)
- AnimationClipDocumentVixen.Editor.AssetEditors
- AnimationGraphDocumentVixen.Editor.AssetEditors
- AnimationWiringTestsVixen.Editor.App.Tests
- AssetPickerTestsVixen.Editor.App.Tests
- AudioMixerDocumentVixen.Editor.AssetEditors
- AuthoringContextTestsVixen.Editor.AssetEditors.Tests
- AuthoringTestsVixen.Editor.AssetEditors.Tests
- BlockoutBooleanVixen.Editor.Blockout
- BlockoutBooleanTestsVixen.Editor.Blockout.Tests
- BlockoutCreateVixen.Editor.Blockout
- BlockoutCreateTestsVixen.Editor.Blockout.Tests
- BlockoutCubeGridVixen.Editor.Blockout
- BlockoutGeometryVixen.Editor.Blockout
- BlockoutGeometryTestsVixen.Editor.Blockout.Tests
- BlockoutHandoffVixen.Editor.Blockout
- BlockoutHistoryTestsVixen.Editor.Blockout.Tests
- BlockoutSurfaceTestsVixen.Editor.Blockout.Tests
- BlockoutSurfacesVixen.Editor.Blockout
- CodeDocumentVixen.Editor.AssetEditors
- CodeDocumentTestsVixen.Editor.AssetEditors.Tests
- CommandStackPropertyTestsVixen.Editor.Core.Tests
- CommandStackTestsVixen.Editor.Core.Tests
- CommandTestsVixen.Editor.NodeGraph.Tests
- CommandTransactionVixen.Editor.Core
- ComponentTestsVixen.Editor.App.Tests
- ComponentsViewVixen.Editor.App
- CompositorViewVixen.Editor.AssetEditors
- DropIntoFieldTestsVixen.Editor.App.Tests
- EditMeshSceneTestsVixen.Editor.SceneView.Tests
- EditPipelineTestsVixen.Editor.Core.Tests
- EditPropertyVixen.Editor.Core
- EditTargetVixen.Editor.Core
- EditingTestsVixen.Editor.Inspector.Tests
- EditorAffordanceTestsVixen.Editor.App.Tests
- EditorApplicationVixen.Editor.App
- EditorDocumentVixen.Editor.Core
- EditorDocumentTestsVixen.Editor.Core.Tests
- EditorProjectVixen.Editor.Core
- EditorPropertyVixen.Editor.Core
- EntityLifetimeTestsVixen.Editor.SceneView.Tests