unity-scene
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBefore 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) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.GET /skills/recommend?includeSchema=true
在调用本模块中的任何技能之前:如果你打算根据技能名称或描述猜测参数来调用技能,请停止——先阅读本文档(或通过获取其 schema)。如果你已经从推荐/schema中获取了参数定义,可以直接进行dryRun。GET /skills/recommend?includeSchema=true
Triggers
触发场景
- Opening or saving scenes
- Loading additively
- Switching active scene
- Querying scene contents
- 打开或保存场景、叠加加载、切换活动场景、查询场景内容
- 打开或保存场景
- 叠加加载场景
- 切换活动场景
- 查询场景内容
- 打开或保存场景、叠加加载、切换活动场景、查询场景内容
Unity Scene Skills
Unity场景技能
Control Unity scenes - the containers that hold all your GameObjects.
控制Unity场景——承载所有GameObject的容器。
Operating Mode
操作模式
- Approval:本模块 Mixed —— /
scene_get_info/scene_get_hierarchy/scene_get_loaded标scene_find_objects,可直接执行;SkillMode.SemiAuto/scene_screenshot/scene_unload未设 Mode 字段(默认 FullAuto),Approval 模式下需 grant。scene_set_active - Auto / Bypass:FullAuto 直接执行。
- 含 NeverInSemi 高危 skill:/
scene_create/scene_load(标scene_save,因为切换/覆盖整个场景文件影响范围极大)。这些在 Approval/Auto 下返RiskLevel="high",仅 Bypass 或 Allowlist 命中可调。MODE_FORBIDDEN
DO NOT (common hallucinations):
- /
scene_deletedo not exist → delete scene files viascene_rename, rename viaasset_deleteasset_move - does not exist → use
scene_list(loaded scenes) orscene_get_loadedwithasset_find(all scene assets)t:Scene - is a simple name/tag/component filter; for regex/layer/path search use
scene_find_objects(SkillMode.SemiAuto, 只读,任何模式可直接调用)gameobject_find
Routing:
- For detailed hierarchy tree → use module's
perceptionhierarchy_describe - For scene statistics → use module's
perceptionscene_summarize - For screenshot → (this module) captures the Game View final composited image (all cameras + UI; in Play mode this is the live runtime frame);
scene_screenshot(camera module, SkillMode.FullAuto) renders a single Game Camera off-screencamera_screenshot
- Approval模式:本模块为Mixed模式——/
scene_get_info/scene_get_hierarchy/scene_get_loaded标记为scene_find_objects,可直接执行;SkillMode.SemiAuto/scene_screenshot/scene_unload未设置Mode字段(默认FullAuto),在Approval模式下需grant权限。scene_set_active - Auto / Bypass模式:FullAuto模式下直接执行。
- 包含NeverInSemi高危技能:/
scene_create/scene_load(标记scene_save,因为切换/覆盖整个场景文件影响范围极大)。这些技能在Approval/Auto模式下返回RiskLevel="high",仅在Bypass或Allowlist命中时可调用。MODE_FORBIDDEN
请勿执行以下操作(常见错误幻觉):
- /
scene_delete不存在→请通过scene_rename删除场景文件,通过asset_delete重命名asset_move - 不存在→请使用
scene_list(已加载场景)或带scene_get_loaded参数的t:Scene(所有场景资源)asset_find - 是简单的名称/标签/组件过滤器;如需正则表达式/层/路径搜索,请使用
scene_find_objects(SkillMode.SemiAuto,只读模式,任何模式下均可直接调用)gameobject_find
路由说明:
- 如需详细层级树→使用模块的
perceptionhierarchy_describe - 如需场景统计→使用模块的
perceptionscene_summarize - 如需截图→本模块的捕获Game View的最终合成图像(所有相机+UI;在Play模式下为实时运行帧);
scene_screenshot(camera模块,SkillMode.FullAuto)渲染单个游戏相机的离线画面camera_screenshot
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
scene_create
Create a new scene.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Path for new scene (e.g., "Assets/Scenes/MyScene.unity") |
创建新场景。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string | 是 | 新场景的路径(例如:"Assets/Scenes/MyScene.unity") |
scene_load
scene_load
Load a scene.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Scene asset path |
| bool | No | false | Load additively (keep current scene) |
加载场景。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 是 | - | 场景资源路径 |
| bool | 否 | false | 叠加加载(保留当前场景) |
scene_save
scene_save
Save the current scene.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | No | Save path (null = save current) |
保存当前场景。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string | 否 | 保存路径(null表示保存当前场景) |
scene_get_info
scene_get_info
Get current scene information.
No parameters.
Returns: — root entries carry , so you can tell which roots are worth descending into before paying for a hierarchy call.
{sceneName, scenePath, isDirty, rootObjectCount, rootObjects: [{name, entityId, instanceId, childCount}]}childCount获取当前场景信息。
无参数。
返回结果: —— 根条目包含,因此你可以在调用层级接口前判断哪些根节点值得展开。
{sceneName, scenePath, isDirty, rootObjectCount, rootObjects: [{name, entityId, instanceId, childCount}]}childCountscene_get_hierarchy
scene_get_hierarchy
Get the scene hierarchy tree, depth-limited.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| int | No | 3 | Maximum hierarchy depth to expand |
Returns: where each node is .
{sceneName, hierarchy: [node, ...]}{name, entityId, instanceId, components: [type, ...], childCount, children}vschildCount— how to tell a leaf from a truncation.childrenis always the node's real number of children, independent ofchildCount;maxDepthischildrenonce the depth limit is reached. So:null
childCountchildrenMeaning 0nullGenuine leaf — nothing below it. > 0nullClipped by — there are children you have not been shown.maxDepth> 0array Fully expanded at this level. Never readas "empty". When you seechildren: nullwithchildCount > 0and you need what is below it, re-call with a largerchildren: null— the default is onlymaxDepth, so deep hierarchies are truncated by default — or query that subtree directly (3,gameobject_findin thehierarchy_describemodule).perception
获取场景层级树,支持深度限制。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| int | 否 | 3 | 展开的最大层级深度 |
返回结果: ,其中每个节点为。
{sceneName, hierarchy: [node, ...]}{name, entityId, instanceId, components: [type, ...], childCount, children}vschildCount—— 如何区分叶子节点与截断节点。children始终是节点的实际子节点数量,与childCount无关;当达到深度限制时,maxDepth为children。因此:null
childCountchildren含义 0null真正的叶子节点——下方无任何内容。 > 0null被 截断——存在未展示的子节点。maxDepth> 0数组 此层级已完全展开。 请勿将视为“空”。当你看到children: null且childCount > 0,同时需要查看下方内容时,请使用更大的children: null重新调用——默认值仅为3,因此深层级结构默认会被截断——或直接查询该子树(maxDepth、gameobject_find模块中的perception)。hierarchy_describe
scene_screenshot
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.
camera_screenshot| 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 ( |
| int | No | 1280 | Only used when |
Returns: . indicates whether the frame is a live runtime image (Play mode) or a static Edit-mode frame. Adds when . If the base64 payload would exceed 8MB, the skill returns an error asking for a smaller — the file at is still saved.
{success, path, width, height, isPlaying, note}isPlaying{imageBase64, imageWidth, imageHeight, imageBytes}returnImage=truemaxDimensionpathAsync: 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 (), so the returned image may be a moment older than the file eventually written to .
ScreenCapture.CaptureScreenshotpathreturnImageScreenCapture.CaptureScreenshotAsTexturepathreturnImage 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.
returnImagepathreturnImage=true捕获Game View的屏幕截图——所有相机+UI的最终合成帧。在Play模式下为实时运行画面,而非Scene/编辑器视图。如需单个游戏相机的渲染画面,请使用。
camera_screenshot| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 否 | "screenshot.png" | 仅文件名(无路径分隔符);保存至 |
| int | 否 | 1920 | 图像宽度 |
| int | 否 | 1080 | 图像高度 |
| bool | 否 | false | 在响应中同时返回Base64格式的PNG图片( |
| int | 否 | 1280 | 仅在 |
返回结果: 。表示帧是实时运行画面(Play模式)还是静态编辑模式画面。当时,会额外返回。如果Base64负载超过8MB,技能会返回错误,要求设置更小的——但对应的文件仍会保存。
{success, path, width, height, isPlaying, note}isPlayingreturnImage=true{imageBase64, imageWidth, imageHeight, imageBytes}maxDimensionpath异步说明: 会在约1帧后写入PNG文件。如果立即读取失败,请等待约200ms后重试。不会读取该文件——因为文件尚未写入——而是同步捕获Game View当前的后台缓冲区(),因此返回的图像可能比最终写入的文件早一帧。
ScreenCapture.CaptureScreenshotpathreturnImageScreenCapture.CaptureScreenshotAsTexturepathreturnImage使用提示: 可读取文件的本地Agent(例如针对本地Unity Editor的Claude Code)通常应省略,待文件写入后直接读取下的PNG文件——这样更节省Token。适用于无法访问Unity项目文件系统的远程/MCP客户端。
returnImagepathreturnImage=truescene_get_loaded
scene_get_loaded
Get list of all currently loaded scenes.
No parameters.
Returns:
{success, scenes: [{name, path, isActive, isDirty}]}获取所有当前已加载场景的列表。
无参数。
返回结果:
{success, scenes: [{name, path, isActive, isDirty}]}scene_unload
scene_unload
Unload a loaded scene (additive).
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Scene name to unload |
卸载已加载的叠加场景。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string | 是 | 要卸载的场景名称 |
scene_set_active
scene_set_active
Set the active scene (for multi-scene editing).
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Scene name to set active |
设置活动场景(用于多场景编辑)。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string | 是 | 要设置为活动状态的场景名称 |
scene_find_objects
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}]}按名称模式、标签或组件类型搜索GameObject。如需高级搜索(正则表达式、层、路径),请使用gameobject_find。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 否 | - | 要匹配的名称子串(不区分大小写) |
| string | 否 | - | 按标签过滤 |
| string | 否 | - | 按组件类型名称过滤 |
| int | 否 | 50 | 返回的最大结果数 |
返回结果:
{success, count, objects: [{name, path, instanceId, active, tag}]}Example Usage
使用示例
python
import unity_skillspython
import unity_skillsCreate a new scene
创建新场景
unity_skills.call_skill("scene_create", scenePath="Assets/Scenes/Level1.unity")
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")
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)
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']}")
info = unity_skills.call_skill("scene_get_info")
print(f"场景: {info['name']}, 对象数量: {info['rootObjectCount']}")
Get full hierarchy (useful for understanding scene structure)
获取完整层级结构(有助于理解场景结构)
hierarchy = unity_skills.call_skill("scene_get_hierarchy", maxDepth=5)
hierarchy = unity_skills.call_skill("scene_get_hierarchy", maxDepth=5)
Save scene
保存场景
unity_skills.call_skill("scene_save")
unity_skills.call_skill("scene_save")
Take screenshot
截取屏幕截图
unity_skills.call_skill("scene_screenshot", filename="preview.png", width=1920, height=1080)
undefinedunity_skills.call_skill("scene_screenshot", filename="preview.png", width=1920, height=1080)
undefinedBest 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
scene_get_info - Screenshots are saved under (filename is a bare name; any path separators are stripped)
Assets/Screenshots/
- 加载新场景前务必保存当前场景
- 对UI叠加层使用叠加加载模式
- 使用空父对象保持场景层级结构有序
- 使用验证场景状态
scene_get_info - 截图保存于目录下(文件名仅为纯名称;任何路径分隔符都会被去除)
Assets/Screenshots/
Exact Signatures
精确签名
Exact names, parameters, defaults, and returns are defined by or , not by this file.
GET /skills/schemaunity_skills.get_skill_schema()精确的名称、参数、默认值和返回值由或定义,而非本文档。
GET /skills/schemaunity_skills.get_skill_schema()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 |
| A required parameter is missing, such as | Provide |
| An invalid tag or component type was passed to | Use a valid tag or component type name, and consider |
| 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). |
完整的传输层错误代码(COMPILING/RATE_LIMIT等)→ ../../references/protocol-error-codes.md
| 错误 | 触发原因 | 修复方案 |
|---|---|---|
| 请求的场景未找到或当前未加载(例如: | 使用 |
| 缺少必填参数,例如 | 提供 |
| 向 | 使用有效的标签或组件类型名称,如需更复杂的过滤器可考虑 |
| 状态约束阻止了操作,例如尝试卸载唯一已加载的场景 | 调整请求至有效的编辑器状态(例如至少保留一个已加载场景)。 |