From 8fbe628458b997d52a2ce5cbd8e9f1d27de1bdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=82=9C=E6=B5=B7?= <35713518+dogodo-cc@users.noreply.github.com> Date: Fri, 29 Jul 2022 16:06:54 +0800 Subject: [PATCH] fix: animation mode hide add-commonent-btn (#12264) * fix: animation mode hide add-commonent-btn * feat: handlerSceneChangeMode return bollean * feat:add isAnimationMode funciton --- editor/inspector/contributions/node.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index ee7f693978..250d238026 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -684,9 +684,12 @@ const Elements = { const panel = this; if (!panel.dump || !panel.dump.isScene) { - panel.toggleShowAddComponentBtn(true); + if (!panel.isAnimationMode()) { + panel.toggleShowAddComponentBtn(true); + } return; } + // 场景模式要隐藏按钮 panel.toggleShowAddComponentBtn(false); panel.$this.setAttribute('sub-type', 'scene'); @@ -1696,9 +1699,11 @@ exports.methods = { toggleShowAddComponentBtn(show) { this.$.componentAdd.style.display = show ? 'inline-block' : 'none'; }, + isAnimationMode() { + return Editor.EditMode.getMode() === 'animation'; + }, handlerSceneChangeMode() { - const mode = Editor.EditMode.getMode(); - this.toggleShowAddComponentBtn(mode !== 'animation'); // 动画编辑模式下,要隐藏按钮 + this.toggleShowAddComponentBtn(!this.isAnimationMode()); // 动画编辑模式下,要隐藏按钮 }, };