| 1234567891011121314151617181920212223242526272829303132 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /* 全局事件中心-订阅发布 */
- public class GlobalEventCenter : MonoBehaviour
- {
- public System.Action onGameSceneLoad;
- public System.Action onGameSceneDestroy;
- public System.Action<bool> onSimulateMouseAwakeChanged; //Param0:激活/熄灭
- public System.Action<bool> onDeviceCalibrateViewAwakeChanged;
- private static GlobalEventCenter _ins;
- public static GlobalEventCenter ins {
- get {
- if (!_ins) {
- _ins = new GameObject("GlobalEventCenter").AddComponent<GlobalEventCenter>();
- DontDestroyOnLoad(_ins);
- }
- return _ins;
- }
- }
- void OnDestroy()
- {
- // 清除静态实例,确保不再持有对该实例的引用
- if (_ins == this)
- {
- _ins = null;
- }
- }
- }
|