Skip to main content

manage_scene

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: legacy  ·  Module: services.tools.manage_scene

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

Description​

Performs CRUD operations on Unity scenes. Read-only validate_references pages broken serialized PPtrs in active_scene/loaded_scenes or an explicit prefab/scriptable_object asset; page_size<=100, max_objects<=250000, max_work<=4000000. Ordinary nulls are excluded; unavailable GUID/fileID evidence is explicit. Read-only actions: get_hierarchy, get_active, get_build_settings, get_loaded_scenes, scene_view_frame. Modifying actions: create (with optional template), load (with optional additive flag), save, close_scene, set_active_scene, move_to_scene, validate (with optional auto_repair). For build settings management (add/remove/enable scenes), use manage_build(action='scenes'). For screenshots, use manage_camera (screenshot, screenshot_multiview actions).

Parameters​

NameTypeRequiredDescription
actionLiteral['create', 'load', 'save', 'get_hierarchy', 'get_active', 'get_build_settings', 'scene_view_frame', 'close_scene', 'set_active_scene', 'get_loaded_scenes', 'move_to_scene', 'validate', 'validate_references']yesPerform CRUD operations on Unity scenes and control the Scene View camera.
namestr | None—Scene name. For Save As, the destination name.
pathstr | None—Scene path under Assets/ or Packages/. For Save As, the destination under Assets/. A bare path is relative to Assets/.
build_indexint | str | None—Unity build index (quote as string, e.g., '0').
allow_overwritebool | str | None—Allow Save As to replace an existing scene.
scene_view_targetstr | int | None—GameObject reference for scene_view_frame (name, path, or instance ID).
parentstr | int | None—Optional parent GameObject reference (name/path/instanceID) to list direct children.
page_sizeint | str | None—Page size for get_hierarchy paging.
cursorint | str | None—Opaque cursor for paging (offset).
max_nodesint | str | None—Hard cap on returned nodes per request (safety).
max_depthint | str | None—Accepted for forward-compatibility; current paging returns a single level.
max_children_per_nodeint | str | None—Child paging hint (safety).
include_transformbool | str | None—If true, include local transform in node summaries.
scene_namestr | None—Loaded scene name. For save, selects the source scene.
scene_pathstr | None—Exact loaded scene path (e.g. 'Assets/Scenes/Level2.unity'). For save, selects the source scene.
targetstr | int | None—GameObject reference (name, path, or instanceID) for move_to_scene.
remove_scenebool | str | None—For close_scene: true to fully remove, false to just unload.
additivebool | str | None—For load: true to open scene additively (keeps current scene).
templatestr | None—For create: scene template ('empty', 'default', '3d_basic', '2d_basic'). Omit for empty scene.
auto_repairbool | str | None—For validate: remove missing scripts after a complete bounded scan. Not undoable; cancellation before commit only; an admitted commit finishes its plan.
max_millisecondsint | str | None—validate: cooperative time budget 1-1000ms, default 25; native calls cannot be interrupted.
continuationstr | None—validate: opaque read-only continuation, valid for five minutes in the same unchanged Editor scene.
reference_scopeLiteral['active_scene', 'loaded_scenes', 'prefab', 'scriptable_object'] | None—validate_references only; loaded scopes never open scenes.
max_objectsint | str | None—validate: 1-10000 objects per slice, default 1000; validate_references: 1-250000, default 1024.
max_workint | str | None—validate_references: maximum 1-4000000 traversal/property steps, default 100000.
page_numberint | str | None—validate_references: 1-based page, maximum page_size 100.
reference_revisionstr | None—validate_references: refuse if the repeated observation has drifted.
reference_snapshotbool | None—validate_references: capture stable paged evidence without rescanning later pages.
reference_cursorstr | None—validate_references: returned snapshot cursor; captured evidence, not a live revision recheck.
verifybool | None—load/save only: observe the exact affected scene with one100-object/10ms validation slice
scene_handleint | None—validate/save: exact scene_handle from get_loaded_scenes. For save, all source selectors must match one loaded scene; omit them to save the active scene.
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​

Load a scene from Assets/Scenes/​

Open Assets/Scenes/MainMenu.unity.

{
"action": "load",
"path": "Scenes/MainMenu.unity"
}

A bare path is relative to Assets/. Forward slashes only.

Load a scene shipped inside a package​

Open the demo scene from com.example.pkg.

{
"action": "load",
"path": "Packages/com.example.pkg/Samples/Demo.unity"
}

A path that already starts with Assets/ or Packages/ is used as-is. Package scenes resolve through the AssetDatabase, so this works for embedded packages and for packages Unity keeps in Library/PackageCache.

Get the scene hierarchy (paged)​

List every GameObject in the active scene.

{
"action": "get_hierarchy",
"page_size": 100
}

Returns up to page_size entries plus a next_cursor for the remainder. Always page large hierarchies.

Save the active scene​

Save the active scene under its existing path.

{ "action": "save" }

Save As to another existing scene requires explicit overwrite consent after reviewing that destination. See the scene and prefab editing guide.

{
"action": "save",
"path": "Assets/Scenes/Existing.unity",
"allow_overwrite": true
}

Create a scene from a template​

Make a new 3D scene called Lab.

{
"action": "create",
"path": "Scenes/Lab.unity",
"template": "3d_basic"
}

Other templates: 2d_basic, default, empty.

Additive multi-scene editing​

Load Scenes/Boss.unity additively while keeping the current scene open.

{
"action": "load",
"path": "Scenes/Boss.unity",
"additive": true
}

Use set_active_scene, close_scene, and move_to_scene to compose multi-scene setups.