using System.Collections; using System.Collections.Generic; using UnityEngine; using UniFramework.Event; using YooAsset; public class GameManager { private static GameManager _instance; public static GameManager Instance { get { if (_instance == null) _instance = new GameManager(); return _instance; } } private readonly EventGroup _eventGroup = new EventGroup(); /// /// 协程启动器 /// public MonoBehaviour Behaviour; private GameManager() { // 注册监听事件 _eventGroup.AddListener(OnHandleEventMessage); _eventGroup.AddListener(OnHandleEventMessage); } /// /// 开启一个协程 /// public void StartCoroutine(IEnumerator enumerator) { Behaviour.StartCoroutine(enumerator); } /// /// 接收事件 /// private void OnHandleEventMessage(IEventMessage message) { if (message is SceneEventDefine.ChangeToHomeScene) { YooAssets.LoadSceneAsync("scene_home"); } else if (message is SceneEventDefine.ChangeToBattleScene) { YooAssets.LoadSceneAsync("scene_battle"); } } }