From 86729cd5ee5acb715bdac765a56ee2026b988ecb Mon Sep 17 00:00:00 2001 From: dgflash Date: Sun, 16 Nov 2025 10:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F=E8=BF=9E?= =?UTF-8?q?=E7=BB=AD=E5=85=B3=E9=97=AD=E7=95=8C=E9=9D=A2=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9C=89=E6=A6=82=E7=8E=87=E5=87=BA=E7=8E=B0=E7=9A=84=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/gui/layer/LayerUI.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/core/gui/layer/LayerUI.ts b/assets/core/gui/layer/LayerUI.ts index 802e7fa..c56a585 100644 --- a/assets/core/gui/layer/LayerUI.ts +++ b/assets/core/gui/layer/LayerUI.ts @@ -170,8 +170,10 @@ export class LayerUI extends Node { if (release === false) this.ui_cache.set(state.config.prefab, state); // 界面移出舞台 - const comp = state.node.getComponent(LayerUIElement)!; - comp.remove(release); + if (state.valid) { + const comp = state.node.getComponent(LayerUIElement); + comp && comp.remove(release); + } } } @@ -180,8 +182,8 @@ export class LayerUI extends Node { const state = this.ui_cache.get(prefabPath); if (state) { this.ui_cache.delete(prefabPath); - const comp = state.node.getComponent(LayerUIElement)!; - comp.remove(true); + const comp = state.node.getComponent(LayerUIElement); + comp && comp.remove(true); } }