private IEnumerator LoadLevelCoroutine(string levelName, int levelIndex) { PersistentDataManager.Record(); // Load the level: PersistentDataManager.LevelWillBeUnloaded(); if (CanLoadAsync()) { AsyncOperation async = !string.IsNullOrEmpty(levelName) ? Tools.LoadLevelAsync(levelName) : Tools.LoadLevelAsync(levelIndex); isLoading = true; while (!async.isDone) { yield return(null); } isLoading = false; } else { if (!string.IsNullOrEmpty(levelName)) { Tools.LoadLevel(levelName); } else { Tools.LoadLevel(levelIndex); } } // Wait two frames for objects in the level to finish their Start() methods: yield return(null); yield return(null); // Apply position data, but don't apply player's position: var player = GameObject.FindGameObjectWithTag("Player"); var persistentPos = (player != null) ? player.GetComponent <PersistentPositionData>() : null; var originalValue = false; if (persistentPos != null) { originalValue = persistentPos.restoreCurrentLevelPosition; persistentPos.restoreCurrentLevelPosition = false; } PersistentDataManager.Apply(); if (persistentPos != null) { persistentPos.restoreCurrentLevelPosition = originalValue; } // Update quest tracker HUD: DialogueManager.SendUpdateTracker(); }
public override void ApplyData(string data) { if (m_appliedImmediate) { m_appliedImmediate = false; if (skipApplyDataAfterFramesIfApplyImmediate) { PersistentDataManager.Apply(); return; } } if (saveRawData) { var rawData = SaveSystem.Deserialize <RawData>(data); if (rawData != null && rawData.bytes != null) { PersistentDataManager.ApplyRawData(rawData.bytes); } } else { PersistentDataManager.ApplySaveData(data); } }
/// <summary> /// Applies the recorded state of the game to the current scene. /// </summary> public void Apply() { PersistentDataManager.Apply(); }