From caff5da8753b5126a9561e9cced3f2bff5451ae2 Mon Sep 17 00:00:00 2001 From: arsen2010 Date: Sun, 25 Jun 2023 14:08:50 +0800 Subject: [PATCH 1/4] fix unlink prefab button visible bug in inspector --- editor/inspector/contributions/node.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index 0edda3f4108..e6b9622533d 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -691,7 +691,16 @@ const Elements = { const prefab = panel.dump.__prefab__; const prefabStateInfo = prefab.prefabStateInfo; - if (prefabStateInfo.assetUuid) { + const canUnlink = panel.dumps.some(dump => { + if (dump.__prefab__ && dump.__prefab__.prefabStateInfo) { + const state = dump.__prefab__.prefabStateInfo.state; + if (state === 2 || state === 3) { + return true; + } + } + return false; + }); + if (canUnlink) { panel.$.prefabUnlink.removeAttribute('disabled'); } else { panel.$.prefabUnlink.setAttribute('disabled', ''); From 82e77c04d265d67cde376908460c66054e5096a8 Mon Sep 17 00:00:00 2001 From: arsen2010 Date: Sun, 25 Jun 2023 14:38:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix=20multiple=20unlink=20prefab=20nodes?= =?UTF-8?q?=EF=BC=8Crecord=20undo=20is=20incorrect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- editor/inspector/contributions/node.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index e6b9622533d..8f3d4591907 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -216,7 +216,6 @@ exports.listeners = { const undoID = await beginRecording(panel.uuidList); const dump = event.target.dump; try { - // Editor.Message.send('scene', 'snapshot'); for (let i = 0; i < panel.uuidList.length; i++) { const uuid = panel.uuidList[i]; if (i > 0) { @@ -637,10 +636,20 @@ const Elements = { return; } - // Editor.Message.send('scene', 'snapshot'); - const role = button.getAttribute('role'); + const recordings = []; + for (const dump of panel.dumps) { + const prefab = dump.__prefab__; + switch (role) { + case 'unlink': + case 'reset': { + recordings.push(prefab.rootUuid); + } + } + } + const undoID = await beginRecording(recordings); + for (const dump of panel.dumps) { const prefab = dump.__prefab__; @@ -654,9 +663,7 @@ const Elements = { break; } case 'unlink': { - const undoID = await beginRecording(prefab.rootUuid); await Editor.Message.request('scene', 'unlink-prefab', prefab.rootUuid, false); - await endRecording(undoID); break; } case 'local': { @@ -664,9 +671,7 @@ const Elements = { break; } case 'reset': { - const undoID = await beginRecording(prefab.rootUuid); await Editor.Message.request('scene', 'restore-prefab', prefab.rootUuid, prefab.uuid); - await endRecording(undoID); break; } case 'save': { @@ -676,6 +681,10 @@ const Elements = { } } } + + if (recordings.length && undoID) { + await endRecording(undoID); + } }); }, async update() { From 511fe8819d4378b589a67c5bbc718db0e012de8b Mon Sep 17 00:00:00 2001 From: arsen2010 Date: Sun, 25 Jun 2023 15:07:46 +0800 Subject: [PATCH 3/4] unlink prefab undo has recorded in scene process --- editor/inspector/contributions/node.js | 1 - 1 file changed, 1 deletion(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index 8f3d4591907..a9eb78a4631 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -642,7 +642,6 @@ const Elements = { for (const dump of panel.dumps) { const prefab = dump.__prefab__; switch (role) { - case 'unlink': case 'reset': { recordings.push(prefab.rootUuid); } From 1d27218b291a658afc5f2ee2a3fc5f2355c99435 Mon Sep 17 00:00:00 2001 From: arsen2010 Date: Sun, 25 Jun 2023 15:17:54 +0800 Subject: [PATCH 4/4] optimize code --- editor/inspector/contributions/node.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index a9eb78a4631..c4a16000369 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -647,7 +647,10 @@ const Elements = { } } } - const undoID = await beginRecording(recordings); + let undoID; + if (recordings.length) { + undoID = await beginRecording(recordings); + } for (const dump of panel.dumps) { const prefab = dump.__prefab__;