fix(prefab): 修复预制体编辑模式的保存与退出,使用原生 scene://edit-mode 接口替代无效的 IPC 广播,更新相关使用文档与安全规定

This commit is contained in:
火焰库拉
2026-03-08 11:33:28 +08:00
parent fb4025e50b
commit 2573c0f478
15 changed files with 443 additions and 13 deletions

View File

@@ -345,6 +345,16 @@ const getToolsList = () => {
description: `保存当前场景的修改`,
inputSchema: { type: "object", properties: {} },
},
{
name: "save_prefab",
description: `保存当前正在编辑的预制体的修改(仅在 open_prefab 进入预制体编辑模式后使用)`,
inputSchema: { type: "object", properties: {} },
},
{
name: "close_prefab",
description: `退出预制体编辑模式,返回普通场景编辑状态`,
inputSchema: { type: "object", properties: {} },
},
{
name: "get_scene_hierarchy",
description: `获取当前场景的节点树结构(包含 UUID、名称、子节点数。若要查询节点组件详情等请使用 manage_components。`,
@@ -1238,6 +1248,24 @@ module.exports = {
callback(null, "场景保存成功。");
break;
case "save_prefab":
isSceneBusy = true;
addLog("info", "调用场景脚本保存预制体...");
callSceneScriptWithTimeout("mcp-bridge", "save-prefab", {}, (err, res) => {
isSceneBusy = false;
callback(err, res);
});
break;
case "close_prefab":
isSceneBusy = true;
addLog("info", "调用场景脚本退出预制体模式...");
callSceneScriptWithTimeout("mcp-bridge", "close-prefab", {}, (err, res) => {
isSceneBusy = false;
callback(err, res);
});
break;
case "get_scene_hierarchy":
callSceneScriptWithTimeout("mcp-bridge", "get-hierarchy", args, callback);
break;