using Cysharp.Threading.Tasks; using UnityEngine.SceneManagement; namespace Script.FrameWork.UI { public class SceneManager : Singleton { public SceneBase CurrentScene { private set; get; } public async UniTask LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode = LoadSceneMode.Single) where T : SceneBase, new() { if (CurrentScene != null) { if (CurrentScene.SceneName == sceneName) { LogHelper.LogError($"Scene already loaded: {sceneName}"); return; } // await CurrentScene.UnLoadSceneAsync(); } CurrentScene = new T(); await CurrentScene.LoadSceneAsync(sceneName, loadSceneMode); } public void Update() { CurrentScene?.OnUpdate(); } } }