Skip to content

Commit 6a2e601

Browse files
committed
Update with building moved to manage_build
1 parent eb16769 commit 6a2e601

9 files changed

Lines changed: 15 additions & 171 deletions

File tree

.claude/skills/unity-mcp-skill/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ uri="file:///full/path/to/file.cs"
178178

179179
| Category | Key Tools | Use For |
180180
|----------|-----------|---------|
181-
| **Scene** | `manage_scene`, `find_gameobjects` | Scene operations, finding objects. Multi-scene editing (additive load, close, set active, move GO between scenes), `modify_build_settings`, scene templates (`3d_basic`, `2d_basic`, `empty`, `default`), scene validation with `auto_repair`. |
181+
| **Scene** | `manage_scene`, `find_gameobjects` | Scene operations, finding objects. Multi-scene editing (additive load, close, set active, move GO between scenes), scene templates (`3d_basic`, `2d_basic`, `empty`, `default`), scene validation with `auto_repair`. For build settings, use `manage_build(action="scenes")`. |
182182
| **Objects** | `manage_gameobject`, `manage_components` | Creating/modifying GameObjects |
183183
| **Scripts** | `create_script`, `script_apply_edits`, `validate_script` | C# code management (auto-refreshes on create/edit) |
184184
| **Assets** | `manage_asset`, `manage_prefabs` | Asset operations. **Prefab instantiation** is done via `manage_gameobject(action="create", prefab_path="...")`, not `manage_prefabs`. |

.claude/skills/unity-mcp-skill/references/tools-reference.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,7 @@ manage_scene(action="close_scene", scene_name="Level2") # Unload sce
190190
manage_scene(action="close_scene", scene_name="Level2", remove_scene=True) # Fully remove
191191
manage_scene(action="move_to_scene", target="Player", scene_name="Level2") # Move root GO
192192

193-
# Build settings management (consolidated)
194-
manage_scene(action="modify_build_settings", scene_path="Assets/Scenes/Level2.unity", operation="add")
195-
manage_scene(action="modify_build_settings", scene_path="Assets/Scenes/Old.unity", operation="remove")
196-
manage_scene(action="modify_build_settings", scene_path="Assets/Scenes/Debug.unity",
197-
operation="set_enabled", enabled=False)
193+
# Build settings — use manage_build(action="scenes") instead
198194

199195
# Scene validation
200196
manage_scene(action="validate") # Detect missing scripts, broken prefabs

MCPForUnity/Editor/Tools/ManageScene.cs

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ private sealed class SceneCommand
6161
public string target { get; set; } // GO reference for move_to_scene
6262
public bool? removeScene { get; set; } // for close_scene
6363
public bool? additive { get; set; } // for load additive mode
64-
public bool? enabled { get; set; } // for modify_build_settings set_enabled
65-
public string operation { get; set; } // for modify_build_settings
6664
public string template { get; set; } // for create with template
6765
public bool? autoRepair { get; set; } // for validate with auto-repair
6866
}
@@ -140,8 +138,6 @@ private static SceneCommand ToSceneCommand(JObject p)
140138
target = (p["target"])?.ToString(),
141139
removeScene = ParamCoercion.CoerceBoolNullable(p["removeScene"] ?? p["remove_scene"]),
142140
additive = ParamCoercion.CoerceBoolNullable(p["additive"]),
143-
enabled = ParamCoercion.CoerceBoolNullable(p["enabled"]),
144-
operation = (p["operation"])?.ToString()?.ToLowerInvariant(),
145141
template = (p["template"])?.ToString()?.ToLowerInvariant(),
146142
autoRepair = ParamCoercion.CoerceBoolNullable(p["autoRepair"] ?? p["auto_repair"]),
147143
};
@@ -283,15 +279,17 @@ public static object HandleCommand(JObject @params)
283279
case "move_to_scene":
284280
return MoveToScene(cmd);
285281
case "modify_build_settings":
286-
return ModifyBuildSettings(cmd);
282+
return new ErrorResponse(
283+
"Build settings management has moved to manage_build (action='scenes'). "
284+
+ "Use manage_build to add, remove, or configure scenes in build settings.");
287285

288286
// Scene validation
289287
case "validate":
290288
return ValidateScene(cmd.autoRepair == true);
291289

292290
default:
293291
return new ErrorResponse(
294-
$"Unknown action: '{action}'. Valid actions: create, load, save, get_hierarchy, get_active, get_build_settings, screenshot, scene_view_frame, close_scene, set_active_scene, get_loaded_scenes, move_to_scene, modify_build_settings, validate."
292+
$"Unknown action: '{action}'. Valid actions: create, load, save, get_hierarchy, get_active, get_build_settings, screenshot, scene_view_frame, close_scene, set_active_scene, get_loaded_scenes, move_to_scene, validate. For build settings, use manage_build."
295293
);
296294
}
297295
}
@@ -1606,67 +1604,7 @@ private static object MoveToScene(SceneCommand cmd)
16061604
return new SuccessResponse($"Moved '{go.name}' to scene '{targetScene.Value.name}'.");
16071605
}
16081606

1609-
private static object ModifyBuildSettings(SceneCommand cmd)
1610-
{
1611-
string op = cmd.operation;
1612-
string scenePath = cmd.scenePath;
1613-
1614-
if (string.IsNullOrEmpty(scenePath))
1615-
return new ErrorResponse("'scenePath' is required for modify_build_settings.");
1616-
if (string.IsNullOrEmpty(op))
1617-
return new ErrorResponse("'operation' is required. Valid operations: add, remove, set_enabled.");
1618-
1619-
var current = new List<EditorBuildSettingsScene>(EditorBuildSettings.scenes);
1620-
1621-
switch (op)
1622-
{
1623-
case "add":
1624-
if (current.Exists(s => s.path == scenePath))
1625-
return new ErrorResponse($"Scene '{scenePath}' is already in build settings.");
1626-
current.Add(new EditorBuildSettingsScene(scenePath, true));
1627-
EditorBuildSettings.scenes = current.ToArray();
1628-
return new SuccessResponse($"Added '{scenePath}' to build settings at index {current.Count - 1}.", new
1629-
{
1630-
scenePath,
1631-
buildIndex = current.Count - 1,
1632-
totalScenes = current.Count
1633-
});
1634-
1635-
case "remove":
1636-
int removed = current.RemoveAll(s => s.path == scenePath);
1637-
if (removed == 0)
1638-
return new ErrorResponse($"Scene '{scenePath}' is not in build settings.");
1639-
EditorBuildSettings.scenes = current.ToArray();
1640-
return new SuccessResponse($"Removed '{scenePath}' from build settings.", new
1641-
{
1642-
scenePath,
1643-
totalScenes = current.Count
1644-
});
1645-
1646-
case "set_enabled":
1647-
if (!cmd.enabled.HasValue)
1648-
return new ErrorResponse("'enabled' (true/false) is required for set_enabled operation.");
1649-
bool found = false;
1650-
var scenes = EditorBuildSettings.scenes;
1651-
for (int i = 0; i < scenes.Length; i++)
1652-
{
1653-
if (scenes[i].path == scenePath)
1654-
{
1655-
scenes[i].enabled = cmd.enabled.Value;
1656-
found = true;
1657-
break;
1658-
}
1659-
}
1660-
if (!found)
1661-
return new ErrorResponse($"Scene '{scenePath}' is not in build settings.");
1662-
EditorBuildSettings.scenes = scenes;
1663-
string state = cmd.enabled.Value ? "enabled" : "disabled";
1664-
return new SuccessResponse($"Scene '{scenePath}' is now {state} in build settings.");
1665-
1666-
default:
1667-
return new ErrorResponse($"Unknown operation: '{op}'. Valid operations: add, remove, set_enabled.");
1668-
}
1669-
}
1607+
// ModifyBuildSettings removed — use manage_build(action="scenes") instead.
16701608

16711609
// ── Scene templates ────────────────────────────────────────────────
16721610

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<details>
2121
<summary><strong>Recent Updates</strong></summary>
2222

23-
* **v9.6.1 (beta)** — QoL extensions: `manage_editor` gains undo/redo actions. `manage_scene` gains multi-scene editing (additive load, close, set active, move GO between scenes), `modify_build_settings`, scene templates (3d_basic, 2d_basic, etc.), and scene validation with auto-repair. New `manage_build` tool: trigger player builds, switch platforms, configure player settings, manage build scenes and profiles (Unity 6+), run batch builds across multiple platforms, and async job tracking with polling. New `MaxPollSeconds` infrastructure for long-running tool operations.
23+
* **v9.6.1 (beta)** — QoL extensions: `manage_editor` gains undo/redo actions. `manage_scene` gains multi-scene editing (additive load, close, set active, move GO between scenes), scene templates (3d_basic, 2d_basic, etc.), and scene validation with auto-repair. New `manage_build` tool: trigger player builds, switch platforms, configure player settings, manage build scenes and profiles (Unity 6+), run batch builds across multiple platforms, and async job tracking with polling. New `MaxPollSeconds` infrastructure for long-running tool operations.
2424
* **v9.5.4** — New `unity_reflect` and `unity_docs` tools for API verification: inspect live C# APIs via reflection and fetch official Unity documentation (ScriptReference, Manual, package docs). New `manage_packages` tool: install, remove, search, and manage Unity packages and scoped registries. Includes input validation, dependency checks on removal, and git URL warnings.
2525
* **v9.5.3** — New `manage_graphics` tool (33 actions): volume/post-processing, light baking, rendering stats, pipeline settings, URP renderer features. 3 new resources: `volumes`, `rendering_stats`, `renderer_features`.
2626
* **v9.5.2** — New `manage_camera` tool with Cinemachine support (presets, priority, noise, blending, extensions), `cameras` resource, priority persistence fix via SerializedProperty.

Server/src/cli/commands/scene.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -318,36 +318,6 @@ def move_to(target: str, scene_name: str):
318318
print_success(f"Moved '{target}' to scene '{scene_name}'")
319319

320320

321-
@scene.command("build-modify")
322-
@click.argument("scene_path")
323-
@click.option("--op", required=True, type=click.Choice(["add", "remove", "set_enabled"]),
324-
help="Operation to perform.")
325-
@click.option("--enable/--disable", "enabled", default=None,
326-
help="For set_enabled: enable or disable.")
327-
@handle_unity_errors
328-
def build_modify(scene_path: str, op: str, enabled: Optional[bool]):
329-
"""Add, remove, or enable/disable a scene in build settings.
330-
331-
\b
332-
Examples:
333-
unity-mcp scene build-modify "Assets/Scenes/Level2.unity" --op add
334-
unity-mcp scene build-modify "Assets/Scenes/OldLevel.unity" --op remove
335-
unity-mcp scene build-modify "Assets/Scenes/Debug.unity" --op set_enabled --disable
336-
"""
337-
config = get_config()
338-
params: dict[str, Any] = {
339-
"action": "modify_build_settings",
340-
"scenePath": scene_path,
341-
"operation": op,
342-
}
343-
if enabled is not None:
344-
params["enabled"] = enabled
345-
result = run_command("manage_scene", params, config)
346-
click.echo(format_output(result, config.format))
347-
if result.get("success"):
348-
print_success(f"Build settings updated: {op} {scene_path}")
349-
350-
351321
# ── Scene validation ─────────────────────────────────────────────────
352322

353323

Server/src/services/tools/manage_scene.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"Performs CRUD operations on Unity scenes. "
1717
"Read-only actions: get_hierarchy, get_active, get_build_settings, get_loaded_scenes, scene_view_frame. "
1818
"Modifying actions: create (with optional template), load (with optional additive flag), save, "
19-
"close_scene, set_active_scene, move_to_scene, modify_build_settings, validate (with optional auto_repair). "
19+
"close_scene, set_active_scene, move_to_scene, validate (with optional auto_repair). "
20+
"For build settings management (add/remove/enable scenes), use manage_build(action='scenes'). "
2021
"For screenshots, use manage_camera (screenshot, screenshot_multiview actions)."
2122
),
2223
annotations=ToolAnnotations(
@@ -38,7 +39,6 @@ async def manage_scene(
3839
"set_active_scene",
3940
"get_loaded_scenes",
4041
"move_to_scene",
41-
"modify_build_settings",
4242
"validate",
4343
], "Perform CRUD operations on Unity scenes and control the Scene View camera."],
4444
name: Annotated[str, "Scene name."] | None = None,
@@ -74,10 +74,6 @@ async def manage_scene(
7474
"For close_scene: true to fully remove, false to just unload."] | None = None,
7575
additive: Annotated[bool | str,
7676
"For load: true to open scene additively (keeps current scene)."] | None = None,
77-
enabled: Annotated[bool | str,
78-
"For modify_build_settings set_enabled operation."] | None = None,
79-
operation: Annotated[str,
80-
"For modify_build_settings: 'add', 'remove', or 'set_enabled'."] | None = None,
8177
# --- Scene template ---
8278
template: Annotated[str,
8379
"For create: scene template ('empty', 'default', '3d_basic', '2d_basic'). Omit for empty scene."] | None = None,
@@ -141,12 +137,6 @@ async def manage_scene(
141137
coerced_additive = coerce_bool(additive, default=None)
142138
if coerced_additive is not None:
143139
params["additive"] = coerced_additive
144-
coerced_enabled = coerce_bool(enabled, default=None)
145-
if coerced_enabled is not None:
146-
params["enabled"] = coerced_enabled
147-
if operation is not None:
148-
params["operation"] = operation
149-
150140
# Scene template
151141
if template is not None:
152142
params["template"] = template

Server/tests/test_manage_scene.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def fake_send(send_fn, unity_instance, tool_name, params):
4141
"create", "load", "save", "get_hierarchy",
4242
"get_active", "get_build_settings", "scene_view_frame",
4343
"close_scene", "set_active_scene", "get_loaded_scenes",
44-
"move_to_scene", "modify_build_settings",
44+
"move_to_scene",
4545
"validate",
4646
]
4747

@@ -86,29 +86,6 @@ def test_move_to_scene_passes_target(mock_unity):
8686
assert mock_unity["params"]["sceneName"] == "Level2"
8787

8888

89-
def test_modify_build_settings_passes_operation_and_path(mock_unity):
90-
result = asyncio.run(manage_scene(
91-
SimpleNamespace(), action="modify_build_settings",
92-
scene_path="Assets/Scenes/Debug.unity",
93-
operation="set_enabled", enabled=False,
94-
))
95-
assert result["success"] is True
96-
assert mock_unity["params"]["operation"] == "set_enabled"
97-
assert mock_unity["params"]["scenePath"] == "Assets/Scenes/Debug.unity"
98-
assert mock_unity["params"]["enabled"] is False
99-
100-
101-
def test_add_to_build_passes_scene_path(mock_unity):
102-
result = asyncio.run(manage_scene(
103-
SimpleNamespace(), action="modify_build_settings",
104-
scene_path="Assets/Scenes/NewLevel.unity",
105-
operation="add",
106-
))
107-
assert result["success"] is True
108-
assert mock_unity["params"]["scenePath"] == "Assets/Scenes/NewLevel.unity"
109-
assert mock_unity["params"]["operation"] == "add"
110-
111-
11289
# ── Template param passthrough ───────────────────────────────────────
11390

11491

@@ -160,7 +137,5 @@ def test_none_params_omitted(mock_unity):
160137
assert "target" not in params
161138
assert "removeScene" not in params
162139
assert "additive" not in params
163-
assert "enabled" not in params
164-
assert "operation" not in params
165140
assert "template" not in params
166141
assert "autoRepair" not in params

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageSceneMultiSceneTests.cs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,43 +63,18 @@ public void MoveToScene_NonExistentGO_ReturnsError()
6363
}
6464

6565
[Test]
66-
public void ModifyBuildSettings_MissingPath_ReturnsError()
67-
{
68-
var p = new JObject
69-
{
70-
["action"] = "modify_build_settings",
71-
["operation"] = "add"
72-
};
73-
var result = ManageScene.HandleCommand(p);
74-
var r = result as JObject ?? JObject.FromObject(result);
75-
Assert.IsFalse(r.Value<bool>("success"));
76-
}
77-
78-
[Test]
79-
public void ModifyBuildSettings_MissingOperation_ReturnsError()
80-
{
81-
var p = new JObject
82-
{
83-
["action"] = "modify_build_settings",
84-
["scenePath"] = "Assets/Scenes/Test.unity"
85-
};
86-
var result = ManageScene.HandleCommand(p);
87-
var r = result as JObject ?? JObject.FromObject(result);
88-
Assert.IsFalse(r.Value<bool>("success"));
89-
}
90-
91-
[Test]
92-
public void ModifyBuildSettings_SetEnabled_MissingEnabled_ReturnsError()
66+
public void ModifyBuildSettings_RedirectsToManageBuild()
9367
{
9468
var p = new JObject
9569
{
9670
["action"] = "modify_build_settings",
9771
["scenePath"] = "Assets/Scenes/Test.unity",
98-
["operation"] = "set_enabled"
72+
["operation"] = "add"
9973
};
10074
var result = ManageScene.HandleCommand(p);
10175
var r = result as JObject ?? JObject.FromObject(result);
10276
Assert.IsFalse(r.Value<bool>("success"));
77+
Assert.IsTrue(r.Value<string>("message").Contains("manage_build"));
10378
}
10479

10580
[Test]

docs/i18n/README-zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<details>
2121
<summary><strong>最近更新</strong></summary>
2222

23-
* **v9.6.1 (beta)** — QoL 扩展:`manage_editor` 新增撤销/重做操作。`manage_scene` 新增多场景编辑(叠加加载、关闭、设置活动场景、跨场景移动物体)、`modify_build_settings`场景模板(3d_basic、2d_basic 等)、场景验证与自动修复。新增 `manage_build` 工具:触发玩家构建、切换平台、配置玩家设置、管理构建场景和配置文件(Unity 6+)、跨多平台批量构建、异步任务跟踪与轮询。新增 `MaxPollSeconds` 基础设施,支持长时间运行的工具操作。
23+
* **v9.6.1 (beta)** — QoL 扩展:`manage_editor` 新增撤销/重做操作。`manage_scene` 新增多场景编辑(叠加加载、关闭、设置活动场景、跨场景移动物体)、场景模板(3d_basic、2d_basic 等)、场景验证与自动修复。新增 `manage_build` 工具:触发玩家构建、切换平台、配置玩家设置、管理构建场景和配置文件(Unity 6+)、跨多平台批量构建、异步任务跟踪与轮询。新增 `MaxPollSeconds` 基础设施,支持长时间运行的工具操作。
2424
* **v9.5.4** — 新增 `unity_reflect``unity_docs` 工具用于 API 验证:通过反射检查实时 C# API,获取官方 Unity 文档(ScriptReference、Manual、包文档)。新增 `manage_packages` 工具:安装、移除、搜索和管理 Unity 包及作用域注册表。包含输入验证、移除时依赖检查和 git URL 警告。
2525
* **v9.5.3** — 新增 `manage_graphics` 工具(33个操作):体积/后处理、光照烘焙、渲染统计、管线设置、URP渲染器特性。3个新资源:`volumes``rendering_stats``renderer_features`
2626
* **v9.5.2** — 新增 `manage_camera` 工具,支持 Cinemachine(预设、优先级、噪声、混合、扩展)、`cameras` 资源、通过 SerializedProperty 修复优先级持久化问题。

0 commit comments

Comments
 (0)