| 123456789101112131415161718192021222324 |
- import { _decorator, Component, Node, EventTarget } from 'cc';
- const { ccclass, property } = _decorator;
- @ccclass('UIEventManager')
- export class UIEventManager extends EventTarget {
- private static _instance: UIEventManager;
- constructor() {
- super();
- if (UIEventManager._instance) {
- // 如果实例已存在,返回这个实例
- return UIEventManager._instance;
- }
- UIEventManager._instance = this;
- }
- public static getInstance(): UIEventManager {
- if (!UIEventManager._instance) {
- UIEventManager._instance = new UIEventManager();
- }
- return UIEventManager._instance;
- }
- }
|