From e9b69f3ec708ac096b3fe1c58fe164a960293e7c Mon Sep 17 00:00:00 2001 From: donggang <> Date: Thu, 29 Feb 2024 20:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/module/common/ModuleUtil.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/assets/module/common/ModuleUtil.ts b/assets/module/common/ModuleUtil.ts index c1d6592..e1a6c76 100644 --- a/assets/module/common/ModuleUtil.ts +++ b/assets/module/common/ModuleUtil.ts @@ -2,11 +2,18 @@ import { Node, __private } from "cc"; import { oops } from "../../core/Oops"; import { UICallbacks } from "../../core/gui/layer/Defines"; import { ecs } from "../../libs/ecs/ECS"; +import { CompType } from "../../libs/ecs/ECSModel"; import { CCComp } from "./CCComp"; import { CCVMParentComp } from "./CCVMParentComp"; -import { CompType } from "../../libs/ecs/ECSModel"; export class ModuleUtil { + /** + * 添加界面组件 + * @param ent 模块实体 + * @param ctor 界面逻辑组件 + * @param uiId 界面资源编号 + * @param uiArgs 界面参数 + */ public static addView( ent: ecs.Entity, ctor: __private._types_globals__Constructor | __private._types_globals__AbstractedConstructor, @@ -21,6 +28,14 @@ export class ModuleUtil { oops.gui.open(uiId, uiArgs, uic); } + /** + * 异步添加视图层组件 + * @param ent 模块实体 + * @param ctor 界面逻辑组件 + * @param uiId 界面资源编号 + * @param uiArgs 界面参数 + * @returns 界面节点 + */ public static addViewAsync( ent: ecs.Entity, ctor: __private._types_globals__Constructor | __private._types_globals__AbstractedConstructor, @@ -38,6 +53,13 @@ export class ModuleUtil { }); } + /** + * 业务实体上移除界面组件 + * @param ent 模块实体 + * @param ctor 界面逻辑组件 + * @param uiId 界面资源编号 + * @param isDestroy 是否释放界面缓存 + */ public static removeView(ent: ecs.Entity, ctor: CompType, uiId: number, isDestroy: boolean = true) { ent.remove(ctor); oops.gui.remove(uiId, isDestroy);