Skip to content

Commit

Permalink
refine of throttleUpdate usage in the node inspector panel (#18030)
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxHuang authored Dec 13, 2024
1 parent a70ecb1 commit dcdbc64
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions editor/inspector/contributions/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ const Elements = {
}, 100, { leading: false, trailing: true });

panel.__nodeChanged__ = (uuid) => {
if (Array.isArray(panel.uuidList) && panel.uuidList.includes(uuid)) {
if (panel.throttleUpdate && Array.isArray(panel.uuidList) && panel.uuidList.includes(uuid)) {
panel.throttleUpdate();
}
};
Expand Down Expand Up @@ -548,7 +548,9 @@ const Elements = {
}
}, 100, { leading: false, trailing: true });

Profile.on('change', panel.__throttleProfileChanged__);
if (panel.__throttleProfileChanged__) {
Profile.on('change', panel.__throttleProfileChanged__);
}

// 识别拖入脚本资源
panel.$.container.addEventListener('dragover', (event) => {
Expand Down Expand Up @@ -645,15 +647,19 @@ const Elements = {
close() {
const panel = this;

panel.throttleUpdate.cancel();
if (panel.throttleUpdate) {
panel.throttleUpdate.cancel();
}
panel.throttleUpdate = undefined;

Editor.Message.removeBroadcastListener('scene:change-node', panel.__nodeChanged__);
Editor.Message.removeBroadcastListener('scene:animation-time-change', panel.__animationTimeChange__);
Editor.Message.removeBroadcastListener('project:setting-change', panel.__projectSettingChanged__);

Profile.removeListener('change', panel.__throttleProfileChanged__);
panel.__throttleProfileChanged__.cancel();
if (panel.__throttleProfileChanged__) {
Profile.removeListener('change', panel.__throttleProfileChanged__);
panel.__throttleProfileChanged__.cancel();
}
panel.__throttleProfileChanged__ = undefined;
},
},
Expand Down

0 comments on commit dcdbc64

Please sign in to comment.