From c973d5db9c138b8f13bdd85c40b3b3f3b5ddc9bd Mon Sep 17 00:00:00 2001 From: DogeFu <609075410@qq.com> Date: Mon, 17 Jul 2023 18:03:03 +0800 Subject: [PATCH 1/5] fix : prefab undo problems removed/apply components undo; revert-prefab undo; --- editor/inspector/contributions/node.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index fb0dbce8e80..7d6c5ddbbd8 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -676,6 +676,11 @@ const Elements = { break; } case 'reset': { + // restore-prefab 内置undo; + if (undoID) { + await endRecording(undoID, true); + undoID = undefined; + } await Editor.Message.request('scene', 'restore-prefab', prefab.rootUuid, prefab.uuid); break; } @@ -1398,7 +1403,7 @@ const Elements = { const panel = this; const sectionMissing = panel.$.sectionMissing; - sectionMissing.addEventListener('click', (event) => { + sectionMissing.addEventListener('click', async (event) => { if (event.target.tagName !== 'UI-ICON') { return; } @@ -1416,6 +1421,10 @@ const Elements = { } const uuidList = panel.uuidList; + let undoId; + if (uuidList.length > 0) { + undoId = await beginRecording(uuidList[0]); + } switch (type) { case 'save-o': { Editor.Message.request('scene', 'apply-removed-component', uuidList[0], info.fileID); @@ -1426,6 +1435,9 @@ const Elements = { break; } } + if (undoId) { + await endRecording(undoId); + } }); }, update() { From 8406557d0cfd73482688550a18db394a08fc5d82 Mon Sep 17 00:00:00 2001 From: DogeFu <609075410@qq.com> Date: Mon, 24 Jul 2023 14:50:03 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E7=9A=84undo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- editor/inspector/contributions/node.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index 7d6c5ddbbd8..9f671e14a7f 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -1403,7 +1403,7 @@ const Elements = { const panel = this; const sectionMissing = panel.$.sectionMissing; - sectionMissing.addEventListener('click', async (event) => { + sectionMissing.addEventListener('click', (event) => { if (event.target.tagName !== 'UI-ICON') { return; } @@ -1421,10 +1421,6 @@ const Elements = { } const uuidList = panel.uuidList; - let undoId; - if (uuidList.length > 0) { - undoId = await beginRecording(uuidList[0]); - } switch (type) { case 'save-o': { Editor.Message.request('scene', 'apply-removed-component', uuidList[0], info.fileID); @@ -1435,9 +1431,6 @@ const Elements = { break; } } - if (undoId) { - await endRecording(undoId); - } }); }, update() { From a896450198ff466cf32c8a72888b082ce40818fa Mon Sep 17 00:00:00 2001 From: DogeFu <609075410@qq.com> Date: Tue, 25 Jul 2023 17:14:03 +0800 Subject: [PATCH 3/5] fix : node._instantiate has different behavior in native scene --- cocos/scene-graph/node.jsb.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cocos/scene-graph/node.jsb.ts b/cocos/scene-graph/node.jsb.ts index 15f31c4beee..3f4308293ce 100644 --- a/cocos/scene-graph/node.jsb.ts +++ b/cocos/scene-graph/node.jsb.ts @@ -1304,20 +1304,13 @@ nodeProto._instantiate = function (cloned: Node, isSyncedNode: boolean) { const newPrefabInfo = (cloned as any)._prefab; if (EDITOR && newPrefabInfo) { if (cloned === newPrefabInfo.root) { + EditorExtends.PrefabUtils.addPrefabInstance?.(cloned); // newPrefabInfo.fileId = ''; } else { // var PrefabUtils = Editor.require('scene://utils/prefab'); // PrefabUtils.unlinkPrefab(cloned); } } - if (EDITOR_NOT_IN_PREVIEW) { - // TODO: Property 'sync' does not exist on type 'PrefabInfo'. - // issue: https://github.com/cocos/cocos-engine/issues/14643 - const syncing = newPrefabInfo && cloned === newPrefabInfo.root && (newPrefabInfo as any).sync; - if (!syncing) { - cloned.name += ' (Clone)'; - } - } // reset and init // NOTE: access protected property From 1903ee1a0209b71aa5e28499126ac25506601949 Mon Sep 17 00:00:00 2001 From: DogeFu <609075410@qq.com> Date: Tue, 25 Jul 2023 17:14:28 +0800 Subject: [PATCH 4/5] Revert "fix : node._instantiate has different behavior in native scene" This reverts commit a896450198ff466cf32c8a72888b082ce40818fa. --- cocos/scene-graph/node.jsb.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/scene-graph/node.jsb.ts b/cocos/scene-graph/node.jsb.ts index 3f4308293ce..15f31c4beee 100644 --- a/cocos/scene-graph/node.jsb.ts +++ b/cocos/scene-graph/node.jsb.ts @@ -1304,13 +1304,20 @@ nodeProto._instantiate = function (cloned: Node, isSyncedNode: boolean) { const newPrefabInfo = (cloned as any)._prefab; if (EDITOR && newPrefabInfo) { if (cloned === newPrefabInfo.root) { - EditorExtends.PrefabUtils.addPrefabInstance?.(cloned); // newPrefabInfo.fileId = ''; } else { // var PrefabUtils = Editor.require('scene://utils/prefab'); // PrefabUtils.unlinkPrefab(cloned); } } + if (EDITOR_NOT_IN_PREVIEW) { + // TODO: Property 'sync' does not exist on type 'PrefabInfo'. + // issue: https://github.com/cocos/cocos-engine/issues/14643 + const syncing = newPrefabInfo && cloned === newPrefabInfo.root && (newPrefabInfo as any).sync; + if (!syncing) { + cloned.name += ' (Clone)'; + } + } // reset and init // NOTE: access protected property From 7c5cf4d721b51dfcd754dd938b7f14d35f009920 Mon Sep 17 00:00:00 2001 From: DogeFu <609075410@qq.com> Date: Mon, 31 Jul 2023 14:05:46 +0800 Subject: [PATCH 5/5] remove reset prefab undo record --- editor/inspector/contributions/node.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index 9f671e14a7f..ac8475e29a9 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -641,20 +641,6 @@ const Elements = { const role = button.getAttribute('role'); - const recordings = []; - for (const dump of panel.dumps) { - const prefab = dump.__prefab__; - switch (role) { - case 'reset': { - recordings.push(prefab.rootUuid); - } - } - } - let undoID; - if (recordings.length) { - undoID = await beginRecording(recordings); - } - for (const dump of panel.dumps) { const prefab = dump.__prefab__; @@ -676,11 +662,6 @@ const Elements = { break; } case 'reset': { - // restore-prefab 内置undo; - if (undoID) { - await endRecording(undoID, true); - undoID = undefined; - } await Editor.Message.request('scene', 'restore-prefab', prefab.rootUuid, prefab.uuid); break; } @@ -691,10 +672,6 @@ const Elements = { } } } - - if (recordings.length && undoID) { - await endRecording(undoID); - } }); }, async update() {