Before calling any skill in this module: if you are about to call a skill with parameters guessed from its name or description, STOP — read this file (or fetch its schema via
GET /skills/recommend?includeSchema=true
) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.
Triggers
- Opening or saving scenes
- Loading additively
- Switching active scene
- Querying scene contents
- 打开或保存场景、叠加加载、切换活动场景、查询场景内容
Unity Scene Skills
Control Unity scenes - the containers that hold all your GameObjects.
Operating Mode
- Approval:本模块 Mixed —— / / / 标 ,可直接执行; / / 未设 Mode 字段(默认 FullAuto),Approval 模式下需 grant。
- Auto / Bypass:FullAuto 直接执行。
- 含 NeverInSemi 高危 skill: / / (标 ,因为切换/覆盖整个场景文件影响范围极大)。这些在 Approval/Auto 下返 ,仅 Bypass 或 Allowlist 命中可调。
DO NOT (common hallucinations):
- / do not exist → delete scene files via , rename via
- does not exist → use (loaded scenes) or with (all scene assets)
- is a simple name/tag/component filter; for regex/layer/path search use (SkillMode.SemiAuto, 只读,任何模式可直接调用)
Routing:
- For detailed hierarchy tree → use module's
- For scene statistics → use module's
- For screenshot → (this module) captures the Game View final composited image (all cameras + UI; in Play mode this is the live runtime frame); (camera module, SkillMode.FullAuto) renders a single Game Camera off-screen
Skills Overview
| Skill | Description |
|---|
| Create a new scene |
| Load a scene |
| Save current scene |
| Get scene information |
| Get hierarchy tree |
| Capture screenshot |
| Get all loaded scenes |
| Unload an additive scene |
| Set active scene |
| Search objects by name/tag/component |
Skills
scene_create
Create a new scene.
| Parameter | Type | Required | Description |
|---|
| string | Yes | Path for new scene (e.g., "Assets/Scenes/MyScene.unity") |
scene_load
Load a scene.
| Parameter | Type | Required | Default | Description |
|---|
| string | Yes | - | Scene asset path |
| bool | No | false | Load additively (keep current scene) |
scene_save
Save the current scene.
| Parameter | Type | Required | Description |
|---|
| string | No | Save path (null = save current) |
scene_get_info
Get current scene information.
No parameters.
Returns:
{sceneName, scenePath, isDirty, rootObjectCount, rootObjects: [{name, entityId, instanceId, childCount}]}
— root entries carry
, so you can tell which roots are worth descending into before paying for a hierarchy call.
scene_get_hierarchy
Get the scene hierarchy tree, depth-limited.
| Parameter | Type | Required | Default | Description |
|---|
| int | No | 3 | Maximum hierarchy depth to expand |
Returns:
{sceneName, hierarchy: [node, ...]}
where each node is
{name, entityId, instanceId, components: [type, ...], childCount, children}
.
vs — how to tell a leaf from a truncation. is always the node's
real number of children, independent of
;
is
once the depth limit is reached. So:
| | Meaning |
|---|
| | Genuine leaf — nothing below it. |
| | Clipped by — there are children you have not been shown. |
| array | Fully expanded at this level. |
Never read
as "empty". When you see
with
and you need what is below it, re-call with a larger
— the default is only
, so deep hierarchies are truncated by default — or query that subtree directly (
,
in the
module).
scene_screenshot
Capture a screenshot of the
Game View — the final composited frame of all cameras + UI. In Play mode this is the live runtime image,
not the Scene/editor view. For a single Game Camera's render use
instead.
| Parameter | Type | Required | Default | Description |
|---|
| string | No | "screenshot.png" | Bare filename only (no path separators); saved under |
| int | No | 1920 | Image width |
| int | No | 1080 | Image height |
| bool | No | false | Also return a PNG as base64 in the response (), for clients without filesystem access |
| int | No | 1280 | Only used when ; downscales the returned image (not the saved file) so its longer edge is ≤ this value. Clamped to 256–4096 |
Returns:
{success, path, width, height, isPlaying, note}
.
indicates whether the frame is a live runtime image (Play mode) or a static Edit-mode frame. Adds
{imageBase64, imageWidth, imageHeight, imageBytes}
when
. If the base64 payload would exceed 8MB, the skill returns an error asking for a smaller
— the file at
is still saved.
Async:
ScreenCapture.CaptureScreenshot
writes the PNG ~1 frame later. If reading
immediately fails, wait ~200ms and retry.
does
not read that file back — since it isn't written yet — it instead does a separate synchronous capture of the Game View's current backbuffer (
ScreenCapture.CaptureScreenshotAsTexture
), so the returned image may be a moment older than the file eventually written to
.
returnImage usage tip: a local agent that can read files (e.g. Claude Code against a local Unity Editor) should generally omit
and just read the PNG at
once it's written — it's cheaper on tokens. Use
for remote/MCP clients that have no filesystem access to the Unity project.
scene_get_loaded
Get list of all currently loaded scenes.
No parameters.
Returns:
{success, scenes: [{name, path, isActive, isDirty}]}
scene_unload
Unload a loaded scene (additive).
| Parameter | Type | Required | Description |
|---|
| string | Yes | Scene name to unload |
scene_set_active
Set the active scene (for multi-scene editing).
| Parameter | Type | Required | Description |
|---|
| string | Yes | Scene name to set active |
scene_find_objects
Search GameObjects by name pattern, tag, or component type. For advanced search (regex, layer, path) use gameobject_find.
| Parameter | Type | Required | Default | Description |
|---|
| string | No | - | Name substring to match (case-insensitive) |
| string | No | - | Filter by tag |
| string | No | - | Filter by component type name |
| int | No | 50 | Max results to return |
Returns:
{success, count, objects: [{name, path, instanceId, active, tag}]}
Example Usage
python
import unity_skills
# Create a new scene
unity_skills.call_skill("scene_create", scenePath="Assets/Scenes/Level1.unity")
# Load an existing scene
unity_skills.call_skill("scene_load", scenePath="Assets/Scenes/MainMenu.unity")
# Load scene additively (multi-scene)
unity_skills.call_skill("scene_load", scenePath="Assets/Scenes/UI.unity", additive=True)
# Get current scene info
info = unity_skills.call_skill("scene_get_info")
print(f"Scene: {info['name']}, Objects: {info['rootObjectCount']}")
# Get full hierarchy (useful for understanding scene structure)
hierarchy = unity_skills.call_skill("scene_get_hierarchy", maxDepth=5)
# Save scene
unity_skills.call_skill("scene_save")
# Take screenshot
unity_skills.call_skill("scene_screenshot", filename="preview.png", width=1920, height=1080)
Best Practices
- Always save before loading a new scene
- Use additive loading for UI overlays
- Keep scene hierarchy organized with empty parent objects
- Use to verify scene state
- Screenshots are saved under (filename is a bare name; any path separators are stripped)
Exact Signatures
Exact names, parameters, defaults, and returns are defined by
or
unity_skills.get_skill_schema()
, not by this file.
Common Errors
Full transport-level codes (COMPILING/RATE_LIMIT etc.) → ../../references/protocol-error-codes.md
| Error | Trigger | Fix |
|---|
| The requested scene is not found or not currently loaded (e.g., , ). | Verify the scene path with or list loaded scenes with , then retry. |
| A required parameter is missing, such as for , or the current scene has no save path. | Provide or save the scene once before the operation. |
| An invalid tag or component type was passed to . | Use a valid tag or component type name, and consider for more complex filters. |
| A state constraint blocked the operation, such as attempting to unload the only loaded scene. | Adjust the request to a valid editor state (e.g., keep at least one scene loaded). |