This commit is contained in:
donggang
2024-03-29 16:55:51 +08:00
parent 278ed90374
commit ba94a6966e

View File

@@ -1,6 +1,7 @@
import { Node, __private } from "cc";
import { oops } from "../../core/Oops";
import { UICallbacks } from "../../core/gui/layer/Defines";
import { ViewUtil } from "../../core/utils/ViewUtil";
import { ecs } from "../../libs/ecs/ECS";
import { CompType } from "../../libs/ecs/ECSModel";
import { CCComp } from "./CCComp";
@@ -14,7 +15,7 @@ export class ModuleUtil {
* @param uiId 界面资源编号
* @param uiArgs 界面参数
*/
public static addView<T extends CCVMParentComp | CCComp>(
public static addViewUi<T extends CCVMParentComp | CCComp>(
ent: ecs.Entity,
ctor: __private._types_globals__Constructor<T> | __private._types_globals__AbstractedConstructor<T>,
uiId: number,
@@ -36,7 +37,7 @@ export class ModuleUtil {
* @param uiArgs 界面参数
* @returns 界面节点
*/
public static addViewAsync<T extends CCVMParentComp | CCComp>(
public static addViewUiAsync<T extends CCVMParentComp | CCComp>(
ent: ecs.Entity,
ctor: __private._types_globals__Constructor<T> | __private._types_globals__AbstractedConstructor<T>,
uiId: number,
@@ -60,8 +61,26 @@ export class ModuleUtil {
* @param uiId 界面资源编号
* @param isDestroy 是否释放界面缓存
*/
public static removeView(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy?: boolean) {
public static removeViewUi(ent: ecs.Entity, ctor: CompType<ecs.IComp>, uiId: number, isDestroy?: boolean) {
ent.remove(ctor);
oops.gui.remove(uiId, isDestroy);
}
/**
* 添加界面组件
* @param ent 模块实体
* @param ctor 界面逻辑组件
* @param parent 显示对象父级
* @param url 显示资源地址
*/
public static addView<T extends CCVMParentComp | CCComp>(
ent: ecs.Entity,
ctor: __private._types_globals__Constructor<T> | __private._types_globals__AbstractedConstructor<T>,
parent: Node,
url: string) {
var node = ViewUtil.createPrefabNode(url);
var comp = node.getComponent(ctor)!;
ent.add(comp);
node.parent = parent;
}
}