diff --git a/assets/core/gui/layer/LayerPopup.ts b/assets/core/gui/layer/LayerPopup.ts index 1b5e12c..6ac6d15 100644 --- a/assets/core/gui/layer/LayerPopup.ts +++ b/assets/core/gui/layer/LayerPopup.ts @@ -18,25 +18,16 @@ export class LayerPopUp extends LayerUI { protected mask!: Node; protected onChildAdded(child: Node) { - this.mask.setSiblingIndex(this.children.length - 2); + this.mask && this.mask.setSiblingIndex(this.children.length - 2); } protected onChildRemoved(child: Node) { - this.mask.setSiblingIndex(this.children.length - 2); + this.mask && this.mask.setSiblingIndex(this.children.length - 2); super.onChildRemoved(child); } protected uiInit(state: UIState): Promise { return new Promise(async (resolve) => { - // 背景半透明遮罩 - if (this.mask == null) { - this.mask = ViewUtil.createPrefabNode(PromptResType.Mask); - this.mask.on(Node.EventType.TOUCH_END, this.onTouchEnd, this); - - this.black = this.mask.addComponent(BlockInputEvents); - this.black.enabled = false; - } - const r = await super.uiInit(state); if (r) { // 界面加载完成显示时,启动触摸非窗口区域关闭 @@ -60,7 +51,7 @@ export class LayerPopUp extends LayerUI { protected closeBlack() { // 所有弹窗关闭后,关闭事件阻挡功能 if (this.ui_nodes.size == 0) { - this.black.enabled = false; + if (this.black) this.black.enabled = false; this.closeVacancyRemove(); } this.closeMask(); diff --git a/assets/module/common/CCEntity.ts b/assets/module/common/CCEntity.ts index 2e9b50c..a4a3b2a 100644 --- a/assets/module/common/CCEntity.ts +++ b/assets/module/common/CCEntity.ts @@ -44,7 +44,7 @@ export class CCEntity extends ecs.Entity { params.preload = true; } - let node = await oops.gui.open(key, params); + const node = await oops.gui.open(key, params); const comp = node.getComponent(ctor) as ecs.Comp; this.add(comp); oops.gui.show(key);