You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
924 B
C#
30 lines
924 B
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace Script.FrameWork.UI
|
|
{
|
|
public class SceneManager : Singleton<SceneManager>
|
|
{
|
|
public SceneBase CurrentScene { private set; get; }
|
|
|
|
public async UniTask LoadSceneAsync<T>(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();
|
|
}
|
|
}
|
|
} |