public SaveableScene prepareNextScene(string sceneName, List <IRestorableGameObject> transferToNextScene, bool loadScene = true) { SaveableScene result = getScene(sceneName); FirstTimeSceneLoaded = !loadScene; ///check if the scene is loaded already if (result == null) { ///if the scene was not loaded, check if it is even existing as a file in the game folder if (sceneExists(sceneName)) { ///if the scene exists in a file load it result = GameDataController.LoadSaveable <SaveableScene>(FolderSystem.getSceneSavePath(GameName, sceneName)); /////create new Scene list. Since its marked as "NonSerialized" its null after loading //AllScenes = new List<SaveableScene>(); addScene(result); } else { ///if the scene doesnt exist in file, create a new scene result = addNewScene(sceneName); ///since the scene was not existing already, "KeepExistingObjects" ///is set to true, as the scene objects ///should not be deleted when first entering a scene FirstTimeSceneLoaded = true; } } CurrentScene = result; CurrentScene.initiateLoadedScene(); CurrentScene.TransferedObjectTree = transferToNextScene; return(result); }
public void loadGame(GamePersistence gameDataController) { SaveableGame.GameDataController = gameDataController; SaveableScene loadedScene = GameDataController.LoadSaveable <SaveableScene> (FolderSystem.getSceneSavePath(GameName, CurrentSceneName)); ///reset scene list so no changes made before loading are interfering AllScenes = new List <SaveableScene>(); addScene(loadedScene); CurrentScene = loadedScene; CurrentScene.initiateLoadedScene(); ///load new scene SceneManager.LoadScene(CurrentSceneName); }