void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Messenger.Broadcast("subscribe"); // Default scene load just returns if (pGameData == null) { Debug.Log("Default scene loaded."); sceneLoadMethod = SceneLoadMethod.Default; return; } Debug.Log("Loading data from pGamedata."); for (int i = 0; i < pGameData.saveableObjectGuids.Length; i++) { // Debug.Log(saveableObjects[i].guid.ToString()); // Debug.Log(pGameData.saveableObjectGuids[i]); SaveableObject saveableObject = SaveableObjectsExcludePlayer.First(s => s.guid.ToString() == pGameData.saveableObjectGuids[i]); saveableObject.Load(pGameData, 0); } // Load Player PlayerSaveable.Load(pGameData, -1); /* * if (sceneLoadedManually) { * // Spawn all saved resources and add them to saveable list * // Player is subscribed through Player.cs Start() method * for (int i = 0; i < pGameData.spawnResources.Length; i++) { * GameObject gameObject = Instantiate(Resources.Load(pGameData.spawnResources[i], typeof(GameObject)), Vector3.zero, Quaternion.identity) as GameObject; * gameObject.GetComponent<SaveableObject>().loadedObject = true; * * saveableObjects.Add(gameObject.GetComponent<SaveableObject>()); * } * * // Load all saveable objects * for (int i = 0; i < saveableObjects.Count; i++) { * saveableObjects[i].Load(pGameData, i); * } * * // Load Player * PlayerSaveable.Load(pGameData, -1); * } */ Managers.PauseMenu.UnpauseGame(); }
// LOAD ALL SCENES USING THE SAVELOADMANAGER public void LoadScene(string scene) { saveableObjects.Clear(); sceneLoadMethod = SceneLoadMethod.ManualLoad; SceneManager.LoadScene(scene); }