public static void LaunchBattleScene() { if (battleScene != null) { Debug.LogError("Battle trying to be launched while battle already active"); return; } if (pausedFreeRoamScene != null) { Debug.LogError("Trying to launch battle scene while there is already a paused scene"); return; } pausedFreeRoamScene = CurrentScene; FreeRoamSceneController pausedSceneController = GetFreeRoamSceneController((Scene)pausedFreeRoamScene); pausedSceneController.SetDoorsEnabledState(false); pausedSceneController.SetSceneRunningState(false); StartFadeOut(); FadeOutComplete += () => { pausedSceneController.SetSceneRunningState(true); pausedSceneController.SetEnabledState(false); int newSceneIndex = SceneManager.sceneCount; AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(battleSceneIdentifier, LoadSceneMode.Additive); loadSceneOperation.completed += (ao) => { battleScene = SceneManager.GetSceneAt(newSceneIndex); Battle.BattleManager battleManager = Battle.BattleManager.GetBattleSceneBattleManager((Scene)battleScene); SceneManager.SetActiveScene((Scene)battleScene); StartFadeIn(); FadeInComplete += () => { battleManager.StartBattle(); }; }; }; }
public static void LaunchBattleScene() { RefreshCurrentSceneStack(); if (battleSceneInUse) { Debug.LogError("Battle trying to be launched while battle already active"); return; } Scene freeRoamScene = sceneRecordStack.Peek().scene; FreeRoamSceneController freeRoamSceneController = GetFreeRoamSceneController(freeRoamScene); freeRoamSceneController.SetDoorsEnabledState(false); freeRoamSceneController.SetSceneRunningState(false); StartFadeOut(); FadeOutComplete += () => { freeRoamSceneController.SetSceneRunningState(true); freeRoamSceneController.SetEnabledState(false); //https://low-scope.com/unity-quick-get-a-reference-to-a-newly-loaded-scene/ int newSceneIndex = SceneManager.sceneCount; AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(battleSceneIdentifier, LoadSceneMode.Additive); loadSceneOperation.completed += (ao) => { battleScene = SceneManager.GetSceneAt(newSceneIndex); battleSceneInUse = true; Battle.BattleManager battleManager = Battle.BattleManager.GetBattleSceneBattleManager(battleScene); SceneManager.SetActiveScene(battleScene); StartFadeIn(); FadeInComplete += () => { battleManager.StartBattle(); }; }; }; }