static void LoadMultiScenes(int activeIndex, bool additive, string[] sceneNames) { OnSceneStartLoadEvent?.Invoke(); int scenes = 0; if (additive) { SceneManager.LoadSceneAsync(sceneNames[scenes], LoadSceneMode.Additive); } else { SceneManager.LoadSceneAsync(sceneNames[scenes]); } void OnSceneManagerOnsceneLoaded(Scene scene, LoadSceneMode mode) { scenes++; if (scenes >= sceneNames.Length) { if (activeIndex != 0 || additive) { SetActiveScene(sceneNames[activeIndex]); } OnSceneEndLoadEvent?.Invoke(); SceneManager.sceneLoaded -= OnSceneManagerOnsceneLoaded; return; } SceneManager.LoadSceneAsync(sceneNames[scenes], LoadSceneMode.Additive); } SceneManager.sceneLoaded += OnSceneManagerOnsceneLoaded; }
public static AsyncOperation LoadSceneAsync(string name, bool isAdditive = false) { OnSceneStartLoadEvent?.Invoke(); void SceneManagerOnsceneLoaded(Scene scene, LoadSceneMode mode) { OnSceneEndLoadEvent?.Invoke(); SceneManager.sceneLoaded -= SceneManagerOnsceneLoaded; } SceneManager.sceneLoaded += SceneManagerOnsceneLoaded; return(LoadSceneAsyncSimple(name, isAdditive)); }
public static IEnumerator ReLoadAdditiveScene(string sceneName) { OnSceneStartLoadEvent?.Invoke(); operation = SceneManager.UnloadSceneAsync(sceneName); yield return(new WaitUntil(() => operation.isDone)); void SceneManagerOnsceneLoaded(Scene scene, LoadSceneMode mode) { OnSceneEndLoadEvent?.Invoke(); SceneManager.sceneLoaded -= SceneManagerOnsceneLoaded; } SceneManager.sceneLoaded += SceneManagerOnsceneLoaded; operation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); }