public abstract class EditorDocumentOne thing open for editing, with its own undo history.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A scene, a material, a prefab, a settings asset. What it holds and how it writes itself back are the deriving type's business; what is here is the part every open document has — a title, an undo stack, and an honest answer to whether it differs from disk.
Dirty has two sources. The stack's own position covers the edits made in this document. The other is a change that arrived from outside it — a global rename that rewrote a reference this document holds — which no amount of undoing inside the document can take back, so it is tracked separately and only Save clears it.
IsStale is the opposite question and is deliberately not part of that answer. Dirty is memory ahead of disk; stale is disk ahead of memory. Folding the two together would make SaveAll write this document over the edit somebody else made to its file. ExternalEdits is what sets it.
⚠ This is not Vixen.Ui's IEditableDocument, and #656 asks for the port. Measured, the two disagree in two places and only two. Name is Title under another name, and Revert is Reload exactly — including the promise that leaves the document dirty and covers both "cannot" and "tried and declined". Neither needs a decision.
⚠ The first real disagreement is what a failed save is. IEditableDocument.Save returns and its means "not written, still dirty". Save here returns nothing and throws through — deliberately, because "a subscriber that cannot write its file is a failed save, and the caller's own error handling is what turns that into a notification". Catching that to answer is the swallow that remark forbids; letting it propagate means an editor document's Save never answers at all, so document.save's failure leg is unreachable here. One of the two has to move, and which is a decision about error reporting rather than a line of glue.
⚠ The second is that this model has no location. A document's identity is Asset, and the only route from one to a path is AssetDatabase.TryGetByGuid plus AssetEntry.Path. Asset is immutable, and EditorApplication opens the main scene as new SceneDocument(project, world, AssetId.Empty, "Main") with the real path held by its Writer — so a straight mapping would have the editor's own scene report Location null, which in IEditableDocument's vocabulary means "never saved" and is what makes Save mean Save As.
⚠ And IsStale has no counterpart there at all, which is the same gap as documents.md's owed "external-modification detection" seen from this side: the mechanism exists here and the framework model has nowhere to put the answer.
Fields and properties (9)
public EditorProject ProjectThe project it belongs to.
public EditorContext ContextWhat commands on this document's stack are handed.
public CommandStack StackThis document's undo history.
public AssetId AssetThe asset it edits, or Empty for one not saved anywhere yet.
public IReadOnlySignal<string> TitleWhat the tab says.
public IReadOnlySignal<bool> IsDirtyWhether it differs from what is on disk.
public IReadOnlySignal<bool> IsStaleWhether its file changed underneath it and it has not caught up.
public bool IsOpenWhether it is still open in the project.
public virtual bool CanReloadWhether this document knows how to read its file again.
Events (1)
public Action<EditorDocument>? SavedRaised after the document has written itself back, before it is marked clean.
Methods (9)
protected EditorDocument(EditorProject project, AssetId asset, string title)Opens a document in a project.
public void SetTitle(string value)Changes what the tab says.
public void Save()Writes it back and records that this is now what is on disk.
public bool Reload()Reads the file again, discarding what was in memory, and forgets the history over it.
protected virtual bool ReloadCore()Reads the file again. Overridden by a document that knows how.
public bool Close()Closes it, which is Close on this document.
protected abstract void SaveCore()Writes the document back to wherever it came from.
protected internal virtual void OnClosed()Called once when the document leaves the project.
protected internal virtual void OnProjectFileChanged(string? path)Something in the project changed on disk, whoever it belongs to.
Used by (242, showing 40)
- ActiveDocumentUndoVixen.Editor.App
- AddCommentCommandVixen.Editor.NodeGraph
- AddGroupCommandVixen.Editor.NodeGraph
- AddNodeCommandVixen.Editor.NodeGraph
- AddressableGroupDocumentVixen.Editor.AssetEditors
- AddressableGroupDocumentTestsVixen.Editor.AssetEditors.Tests
- AddressableGroupEditorFactoryVixen.Editor.AssetEditors
- AddressableGroupsViewVixen.Editor.AssetEditors
- AnimationBinderVixen.Editor.AssetEditors
- AnimationClipDocumentVixen.Editor.AssetEditors
- AnimationClipEditorFactoryVixen.Editor.AssetEditors
- AnimationGraphDocumentVixen.Editor.AssetEditors
- AnimationGraphEditorFactoryVixen.Editor.AssetEditors
- AnimationWiringTestsVixen.Editor.App.Tests
- AssetEditorRegistryVixen.Editor.AssetEditors
- AssetEditorRegistryTestsVixen.Editor.AssetEditors.Tests
- AssetPickerTestsVixen.Editor.App.Tests
- AudioMixerDocumentVixen.Editor.AssetEditors
- AudioMixerEditorFactoryVixen.Editor.AssetEditors
- AudioMixerViewTestsVixen.Editor.AssetEditors.Tests
- AuthoringContextTestsVixen.Editor.AssetEditors.Tests
- AuthoringTestsVixen.Editor.AssetEditors.Tests
- BehaviorTreeDocumentVixen.Editor.AssetEditors
- BehaviorTreeDocumentTestsVixen.Editor.AssetEditors.Tests
- BehaviorTreeEditorFactoryVixen.Editor.AssetEditors
- BlankDocumentVixen.Editor.App.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
- BlockoutKnifeTestsVixen.Editor.Blockout.Tests
- BlockoutRetopologyVixen.Editor.Blockout
- BlockoutRetopologyTestsVixen.Editor.Blockout.Tests
- BlockoutSurfaceTestsVixen.Editor.Blockout.Tests
- BlockoutSurfacesVixen.Editor.Blockout