import { AudioConst } from "../../data/const/TypeConst"; import GameDataCenter from "../../data/GameDataCenter"; import EventMng from "../../manager/EventMng"; import { uiCommon } from "../../utils/UICommon"; import { BtnEvent } from "../fgui/mvc/FguiViewCtrl"; import { Constructor } from "./Fundation"; declare global { type UEClass = Constructor & { readonly BundleKey: string; readonly PrefabUrl: string; readonly CLS: string; // OnCollectResStatic?: (resCollector: IResCollector) => void; } } const { ccclass, property } = cc._decorator; @ccclass export default abstract class UEBase extends cc.Component { /**通知事件列表 */ private _notifyEventList: Map = new Map(); registerCount: number = 0 /**onLoad 会在组件被首次加载的时候被回调。且优先于任何start */ onLoad() { } onDestroy() { try { let self = this; this._notifyEventList.forEach((f, key) => { // console.log("_notifyEventList key = "+key) EventMng.off(key, f, self); }, this); this._notifyEventList.clear(); } catch (error) { console.error("onDisable->" + error) } if (this.registerCount > 0) { console.error(this.name + " 按钮注册后没off掉啊喂 \n(╯-_-)╯╧╧ ") } } /**注册notice事件,disable的时候会自动移除 */ initEvent(eventName: string, cb: Function) { EventMng.on(eventName, cb, this); this._notifyEventList.set(eventName, cb); } RegisterClick(node: cc.Node, callback, target = null, params: any = [], audio: AudioConst = AudioConst.effect_click) { uiCommon.onRegisterEvent(node, callback, target, params, audio) } RemoveAllClick() { uiCommon.unRegisterEvent(this.node) } }