Skip to main content

manage_scene_edits

Auto-generated from the Python tool registry. Do not hand-edit outside <!-- examples:start --><!-- examples:end --> blocks — the generator (tools/generate_docs_reference.py) will overwrite them.

Group: core  ·  Module: services.tools.manage_scene_edits

Maturity: stable (support status; independent of enabled state, readiness and permissions).

Description​

Preview or apply 1-1000 allowlisted native Transform, BoxCollider, SphereCollider, Rigidbody, or CapsuleCollider serialized property edits in a stable Edit-mode scene. Preview returns before/after values and a one-attempt token valid for 10 minutes. Apply accepts preview_id, or edits with expected_old for every field. Rejects drift before mutation; apply returns receipt_id. Use undo with this receipt to restore unchanged applied fields and report conflicts with before, applied and current values. Also accepts a receipt from prefab_contents apply_preview. No arbitrary transaction or filesystem, build, package, custom callback, dirty-flag rollback is promised. preview_structure takes an integer scene-root target scope and 1-256 ordered create/delete/reparent operations. Only ordinary Transform-only subtrees are supported; prefab instances and custom/native component subtrees are refused. create assigns a $temporary ID that later operations may reference. reparent preserves local transforms. apply_structure requires the preview token and rejects hierarchy/state drift before its one Undo group.

Parameters​

NameTypeRequiredDescription
actionLiteral['preview', 'apply', 'undo', 'preview_structure', 'apply_structure']yes
editslist[SceneEdit] | None—
preview_idstr | None—
undo_namestr—
targetint | None—
operationslist[StructureCreate | StructureReparent | StructureDelete] | None—
receipt_idstr | None—
unity_instancestr | int | None—Target Unity instance for this call: Name@hash or hash prefix; an integer selects only that exact port over stdio and is rejected over HTTP. Read mcpforunity://instances for available targets. Omit to use the legacy active selection or the sole available instance.

Returns​

A dict containing the Unity response. The exact shape depends on the action.

Examples​

See the scene and prefab editing guide for scope, drift checks and recovery. These are tool arguments; replace paths and IDs with verified project values. Run in a stable Edit-mode scene.

Preview an existing object's local position:

{
"action": "preview",
"edits": [
{
"target": "Player",
"search_method": "by_path",
"component_type": "Transform",
"property": "localPosition",
"value": [1, 2, 3]
}
]
}

Review the returned before/after values, then replace REPLACE_WITH_RETURNED_PREVIEW_ID with that response's preview_id. Do not also send edits:

{
"action": "apply",
"preview_id": "REPLACE_WITH_RETURNED_PREVIEW_ID",
"undo_name": "Move reviewed player"
}

For structural edits, replace -123 with the current ID of an ordinary Transform-only scene root. Temporary IDs can refer only to an earlier create operation in this request:

{
"action": "preview_structure",
"target": -123,
"operations": [
{"op": "create", "temp_id": "$group", "name": "Props", "parent": -123},
{"op": "create", "temp_id": "$child", "name": "Marker", "parent": "$group"}
]
}

Review the hierarchy impact, then use the token returned by that structural preview:

{
"action": "apply_structure",
"preview_id": "REPLACE_WITH_RETURNED_PREVIEW_ID",
"undo_name": "Create reviewed markers"
}

Each token permits one attempt within ten minutes. Re-preview after expiry or drift. Successful apply records one Undo group; scene saving remains explicit.