Problem
create_hierarchy creates a tree, adds components, and applies serialized properties without wrapping the whole client-facing operation in one Undo group. Property application also bypasses Undo.RecordObject.
Evidence
Editor/MCPServerMethods.Hierarchy.cs:47-56 recursively creates objects and mutates them after Undo.RegisterCreatedObjectUndo.
Editor/MCPServerMethods.Hierarchy.cs:61-68 adds components through Undo.AddComponent per component.
Editor/MCPServerMethods.Hierarchy.cs:71-107 applies component properties via SerializedObject.ApplyModifiedProperties() without Undo.RecordObject.
- There is no
Undo.SetCurrentGroupName / Undo.CollapseUndoOperations around the whole hierarchy creation.
Impact
A single create_hierarchy RPC can produce multiple Undo entries and non-undo-tracked property changes, making the operation non-atomic from a Unity user perspective.
Suggested fix
Wrap the full operation in a named Undo group, record component objects before property mutation, and collapse the group before returning.
Source report
Imported from audit report items:
unity-antipattern (6) / Editor/MCPServerMethods.Hierarchy.cs:47
unity-antipattern (6) / Editor/MCPServerMethods.Hierarchy.cs:71
Grouped because both describe the same create_hierarchy Undo contract gap.
Problem
create_hierarchycreates a tree, adds components, and applies serialized properties without wrapping the whole client-facing operation in one Undo group. Property application also bypassesUndo.RecordObject.Evidence
Editor/MCPServerMethods.Hierarchy.cs:47-56recursively creates objects and mutates them afterUndo.RegisterCreatedObjectUndo.Editor/MCPServerMethods.Hierarchy.cs:61-68adds components throughUndo.AddComponentper component.Editor/MCPServerMethods.Hierarchy.cs:71-107applies component properties viaSerializedObject.ApplyModifiedProperties()withoutUndo.RecordObject.Undo.SetCurrentGroupName/Undo.CollapseUndoOperationsaround the whole hierarchy creation.Impact
A single
create_hierarchyRPC can produce multiple Undo entries and non-undo-tracked property changes, making the operation non-atomic from a Unity user perspective.Suggested fix
Wrap the full operation in a named Undo group, record component objects before property mutation, and collapse the group before returning.
Source report
Imported from audit report items:
unity-antipattern (6)/Editor/MCPServerMethods.Hierarchy.cs:47unity-antipattern (6)/Editor/MCPServerMethods.Hierarchy.cs:71Grouped because both describe the same
create_hierarchyUndo contract gap.