fix(main): 为资源管理操作添加 'save' 别名兼容 AI 幻觉
This commit is contained in:
@@ -202,3 +202,8 @@
|
|||||||
|
|
||||||
- **问题**: AI 助手在使用 `manage_components` 尝试修改 `Label` 位置时,错误地对组件传参 `{ node: { position: ... } }`,导致 Label 的 `this.node` 强引用被覆写为普通对象。引发渲染报错 (`Cannot read property 'a' of undefined`) 和删除卡死 (`this.node._removeComponent is not a function`)。
|
- **问题**: AI 助手在使用 `manage_components` 尝试修改 `Label` 位置时,错误地对组件传参 `{ node: { position: ... } }`,导致 Label 的 `this.node` 强引用被覆写为普通对象。引发渲染报错 (`Cannot read property 'a' of undefined`) 和删除卡死 (`this.node._removeComponent is not a function`)。
|
||||||
- **修复**: 在 `scene-script.js` 的 `applyProperties` 中增加了核心属性黑名单机制。强制拦截对 `node`, `uuid`, `_id` 的直接写入并给出警告。彻底杜绝由于组件的节点引用被破坏所引发的场景崩溃和编辑器卡死问题。
|
- **修复**: 在 `scene-script.js` 的 `applyProperties` 中增加了核心属性黑名单机制。强制拦截对 `node`, `uuid`, `_id` 的直接写入并给出警告。彻底杜绝由于组件的节点引用被破坏所引发的场景崩溃和编辑器卡死问题。
|
||||||
|
|
||||||
|
### 2. 资源管理层 `save` 动作幻觉别名兼容
|
||||||
|
|
||||||
|
- **问题**: AI 偶尔会幻觉以为 `prefab_management`/`manage_script`/`manage_material`/`manage_texture`/`manage_shader` 的更新动作为 `save`,而不是标准定义的 `update` 或 `write`,导致抛出“未知的管理操作”报错。
|
||||||
|
- **修复**: 在 `main.js` 所有这些管理工具的核心路由表中,为 `update` 和 `write` 操作均显式添加了 `case "save":` 作为后备兼容,极大地增强了不同大模型在不同提示词上下文环境下的操作容错率。
|
||||||
|
|||||||
5
main.js
5
main.js
@@ -1292,6 +1292,7 @@ export default class NewScript extends cc.Component {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "save": // 兼容 AI 幻觉
|
||||||
case "write":
|
case "write":
|
||||||
// 使用 fs 写入 + refresh,确保覆盖成功
|
// 使用 fs 写入 + refresh,确保覆盖成功
|
||||||
const writeFsPath = Editor.assetdb.urlToFspath(scriptPath);
|
const writeFsPath = Editor.assetdb.urlToFspath(scriptPath);
|
||||||
@@ -1548,6 +1549,7 @@ export default class NewScript extends cc.Component {
|
|||||||
callback(null, `指令已发送: 从节点 ${nodeId} 在目录 ${targetDir} 创建名为 ${prefabName} 的预制体`);
|
callback(null, `指令已发送: 从节点 ${nodeId} 在目录 ${targetDir} 创建名为 ${prefabName} 的预制体`);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "save": // 兼容 AI 幻觉
|
||||||
case "update":
|
case "update":
|
||||||
if (!nodeId) {
|
if (!nodeId) {
|
||||||
return callback("更新预制体需要节点 ID");
|
return callback("更新预制体需要节点 ID");
|
||||||
@@ -1723,6 +1725,7 @@ CCProgram fs %{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "save": // 兼容 AI 幻觉
|
||||||
case "write":
|
case "write":
|
||||||
if (!Editor.assetdb.exists(effectPath)) {
|
if (!Editor.assetdb.exists(effectPath)) {
|
||||||
return callback(`Effect not found: ${effectPath}`);
|
return callback(`Effect not found: ${effectPath}`);
|
||||||
@@ -1803,6 +1806,7 @@ CCProgram fs %{
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "save": // 兼容 AI 幻觉
|
||||||
case "update":
|
case "update":
|
||||||
if (!Editor.assetdb.exists(matPath)) {
|
if (!Editor.assetdb.exists(matPath)) {
|
||||||
return callback(`找不到材质: ${matPath}`);
|
return callback(`找不到材质: ${matPath}`);
|
||||||
@@ -1963,6 +1967,7 @@ CCProgram fs %{
|
|||||||
callback(`找不到纹理: ${path}`);
|
callback(`找不到纹理: ${path}`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "save": // 兼容 AI 幻觉
|
||||||
case "update":
|
case "update":
|
||||||
if (!Editor.assetdb.exists(path)) {
|
if (!Editor.assetdb.exists(path)) {
|
||||||
return callback(`找不到纹理: ${path}`);
|
return callback(`找不到纹理: ${path}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user