public sealed class ReparentCommandMoving entities to a new parent, as something the undo stack can take back.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Doc 20's B1 lists "drag-to-reparent (undoably — the primitive Hierarchy.SetParentAfter exists, the command does not)", and this is the command. SceneDocument.Reparent said as much in its own remarks: reparenting is reversible, and undoing it has to put the entity back among its old siblings where it was rather than at the head of them.
⚠ The position is recorded as a neighbour, not an index. An index would have to be counted from the head, would be invalidated by every insertion before it, and would mean nothing once a sibling was itself deleted. The entity that used to be in front is stable under all three, and it is what the intrusive sibling list already stores — so restoring is a link rather than a walk. Hierarchy.SetParentAfter's own remarks make the same argument from the other side.
⚠ A root has no neighbour to record, and that is not an oversight. Roots are not a sibling list — the scene finds them by walking every entity with no parent — so an entity undone back to the root set comes back in creation order rather than where it was dragged from. Making that exact needs the scene to hold a root order, which is a change to the format rather than to this.
⚠ The world position is kept, which is what a drag in an outliner means. Dragging a crate onto a shelf should not teleport it inside the shelf's local space; every editor behaves this way and the one that does not is reported as a bug on the first afternoon.
Fields and properties (3)
public string NameWhat this is called in the undo history, as a person would say it.
public bool IsEmptyWhether there is nothing left to do.
public int CountHow many entities this moves.
Methods (4)
public ReparentCommand(SceneDocument document, IEnumerable<Entity> entities, Entity parent)Describes a move that has not happened yet.
public void Do(EditorContext context)Applies the change.
public void Undo(EditorContext context)public bool TryMergeWith(IEditorCommand previous, out IEditorCommand? merged)
Used by (1)
- SceneDocumentVixen.Editor.SceneView