using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using CG.Framework; /******************************************************************************* *Create By CG *Function 非异步场景加载控制 *******************************************************************************/ namespace CG.UTility { public class LoadScenes: MonoSingleton { private System.Action _loadedCall = null; protected override void AwakeSelf() { base.AwakeSelf(); SceneManager.sceneLoaded += SceneManager_sceneLoaded; } public void LoadScene(string sceneName, System.Action LoadedCall) { _loadedCall = LoadedCall; SceneManager.LoadScene(sceneName); } protected override void OnDestroy() { base.OnDestroy(); SceneManager.sceneLoaded -= SceneManager_sceneLoaded; } private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) { _loadedCall?.Invoke(); } } }