using System.Collections; using UnityEngine; using UnityEngine.SceneManagement; namespace UFS3.Management { public class SceneManager : MonoBehaviour { public static SceneManager Instance; public static void LoadAsync(string sceneName, LoadSceneMode mode) { if (Instance == null) { Instance = new GameObject("SceneManager").AddComponent(); } Instance.StartCoroutine(Instance.LoadGameScene(sceneName, mode)); } public static void UnloadScene(string sceneName) { if (!UnityEngine.SceneManagement.SceneManager.GetSceneByName(sceneName).isLoaded) { Debug.LogWarning("Scene '" + sceneName + "' is not currently loaded."); return; } UnityEngine.SceneManagement.SceneManager.UnloadScene(sceneName); Debug.Log("Scene '" + sceneName + "' unloaded successfully."); } private IEnumerator LoadGameScene(string sceneName, LoadSceneMode mode) { AsyncOperation ao = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName, mode); while (!ao.isDone) { yield return null; } } } }