Vixen
dd8b0a81
csharp
public sealed class InstantiateSubtreeCommand

Putting a whole subtree into a scene at once, undoably.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

What a prefab drop is, and what CreateEntityCommand cannot be. That command makes one entity and takes its components from an Initialise callback; placing a prefab makes a root and everything below it, and how many entities that is is the file's business rather than the command's. So the caller supplies the making and this supplies the undo.

⚠ The subtree is made by Do and only ever once. A redo restores the snapshot the undo took, which already holds every entity, every component, every name, every stable id and every prefab link — running the factory again would place a second instance with fresh handles, and every reference to the first would then be addressing nothing. That is Initialise's rule, at subtree scale.

⚠ A factory that makes nothing is not an error here. A prefab whose file has gone between the drag and the drop is a real case; the command then has no subtree, undoes to nothing and redoes to nothing rather than throwing out of a gesture.

Fields and properties (2)

  • public string Name

    What this is called in the undo history, as a person would say it.

  • public Entity Entity

    The subtree's root, once Do has run.

Methods (5)

  • public InstantiateSubtreeCommand(SceneDocument document, string name, Func<Entity> make)

    Describes placing a subtree.

  • public void Do(EditorContext context)

    Applies the change.

  • public void Undo(EditorContext context)

    Puts back exactly what Do changed.

  • public bool TryMergeWith(IEditorCommand previous, out IEditorCommand? merged)
  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (1)

  • SceneDocumentVixen.Editor.SceneView