/** * <summary>Loads a new scene. This method should be used instead of Unity's own scene-switching method, because this allows for AC objects to be saved beforehand</summary> * <param name = "nextSceneInfo">Info about the scene to load</param> * <param name = "sceneNumber">The number of the scene to load, if sceneName = ""</param> * <param name = "saveRoomData">If True, then the states of the current scene's Remember scripts will be recorded in LevelStorage</param> * <param name = "forceReload">If True, the scene will be re-loaded if it is already open.</param> * <param name = "_removeNPCID">If non-zero, then an NPC with a Constant ID of this number will be removed after the scene-change</param> */ public void ChangeScene(SceneInfo nextSceneInfo, bool saveRoomData, bool forceReload = false, int _removeNPCID = 0) { removeNPCID = 0; if (!isLoading) { if (!nextSceneInfo.Matches(thisSceneInfo) || forceReload) { if (preloadSceneInfo != null && preloadSceneInfo.IsValid() && !preloadSceneInfo.Matches(nextSceneInfo)) { ACDebug.LogWarning("Opening scene '" + nextSceneInfo.GetLabel() + "', but have preloaded scene '" + preloadSceneInfo.GetLabel() + "'. Preloaded data must be scrapped."); if (preloadAsync != null) { preloadAsync.allowSceneActivation = true; } preloadSceneInfo = null; } removeNPCID = _removeNPCID; PrepareSceneForExit(!KickStarter.settingsManager.useAsyncLoading, saveRoomData); LoadLevel(nextSceneInfo, KickStarter.settingsManager.useLoadingScreen, KickStarter.settingsManager.useAsyncLoading, forceReload); } } }
/** * <summary>Loads a new scene. This method should be used instead of Unity's own scene-switching method, because this allows for AC objects to be saved beforehand</summary> * <param name = "nextSceneInfo">Info about the scene to load</param> * <param name = "sceneNumber">The number of the scene to load, if sceneName = ""</param> * <param name = "saveRoomData">If True, then the states of the current scene's Remember scripts will be recorded in LevelStorage</param> * <param name = "forceReload">If True, the scene will be re-loaded if it is already open.</param> * <param name = "_takeNPCPosition">If True, and _revemoNPCID is non-zero, then the Player will teleport to the NPC's position before the NPC is removed</param> */ public void ChangeScene(SceneInfo nextSceneInfo, bool saveRoomData, bool forceReload = false, bool _takeNPCPosition = false) { takeNPCPosition = false; if (!isLoading) { if (!nextSceneInfo.Matches(thisSceneInfo) || forceReload) { if (preloadSceneInfo != null && preloadSceneInfo.IsValid() && !preloadSceneInfo.Matches(nextSceneInfo)) { ACDebug.LogWarning("Opening scene '" + nextSceneInfo.GetLabel() + "', but have preloaded scene '" + preloadSceneInfo.GetLabel() + "'. Preloaded data must be scrapped."); if (preloadAsync != null) { preloadAsync.allowSceneActivation = true; } preloadSceneInfo = null; } takeNPCPosition = _takeNPCPosition; PrepareSceneForExit(!KickStarter.settingsManager.useAsyncLoading, saveRoomData); LoadLevel(nextSceneInfo, KickStarter.settingsManager.useLoadingScreen, KickStarter.settingsManager.useAsyncLoading, forceReload); } } else { ACDebug.LogWarning("Cannot switch scene while another scene-loading operation is underway."); } }
public void PreloadScene(SceneInfo nextSceneInfo) { if (preloadSceneInfo != null && preloadSceneInfo.Matches(nextSceneInfo)) { ACDebug.Log("Skipping preload of scene '" + nextSceneInfo.GetLabel() + "' - already preloaded."); return; } StartCoroutine(PreloadLevelAsync(nextSceneInfo)); }
override public float Run() { SceneInfo sceneInfo = new SceneInfo(chooseSceneBy, AdvGame.ConvertTokens(sceneName), sceneNumber); if (!isRunning) { waitedOneMoreFrame = false; isRunning = true; if (KickStarter.sceneSettings.OverridesCameraPerspective()) { ACDebug.LogError("The current scene overrides the default camera perspective - this feature should not be used in conjunction with multiple-open scenes."); } if (sceneAddRemove == SceneAddRemove.Add) { if (KickStarter.sceneChanger.AddSubScene(sceneInfo)) { return(defaultPauseTime); } } else if (sceneAddRemove == SceneAddRemove.Remove) { KickStarter.sceneChanger.RemoveScene(sceneInfo); } } else { if (!waitedOneMoreFrame) { waitedOneMoreFrame = true; return(defaultPauseTime); } if (sceneAddRemove == SceneAddRemove.Add) { bool found = false; foreach (SubScene subScene in KickStarter.sceneChanger.GetSubScenes()) { if (subScene.SceneInfo.Matches(sceneInfo)) { found = true; if (runCutsceneOnStart && subScene.SceneSettings != null && subScene.SceneSettings.cutsceneOnStart != null) { subScene.SceneSettings.cutsceneOnStart.Interact(); } } } if (!found) { LogWarning("Adding a non-AC scene additively! A GameEngine prefab must be placed in scene '" + sceneInfo.GetLabel() + "'."); } } isRunning = false; } return(0f); }
override public float Run() { SceneInfo sceneInfo = new SceneInfo(chooseSceneBy, sceneName, sceneNumber); if (!isRunning) { isRunning = true; if (sceneAddRemove == SceneAddRemove.Add) { if (KickStarter.sceneChanger.AddSubScene(sceneInfo)) { return(defaultPauseTime); } } else if (sceneAddRemove == SceneAddRemove.Remove) { KickStarter.sceneChanger.RemoveScene(sceneInfo); } } else { if (sceneAddRemove == SceneAddRemove.Add) { bool found = false; foreach (SubScene subScene in KickStarter.sceneChanger.GetSubScenes()) { if (subScene.SceneInfo.Matches(sceneInfo)) { found = true; if (runCutsceneOnStart && subScene.SceneSettings != null && subScene.SceneSettings.cutsceneOnStart != null) { subScene.SceneSettings.cutsceneOnStart.Interact(); } } } if (!found) { ACDebug.LogWarning("Adding a non-AC scene additively! A GameEngine prefab must be placed in scene '" + sceneInfo.GetLabel() + "'."); } } isRunning = false; } return(0f); }