/// <summary> /// Initializes SvgManager.SvgData with serialized entry from PlayerPrefs (or create a blank instance if no saved game yet) /// </summary> private void loadSvgData() { XmlSerializer serializer = new XmlSerializer(typeof(SvgSerializableData)); using (StringReader reader = new StringReader(PlayerPrefs.GetString(SavedGameName))) { if (PlayerPrefs.HasKey(SavedGameName)) { SvgData = serializer.Deserialize(reader) as SvgSerializableData; //We overwrite the Upgrades list that is used in the game, with the values of the saved data UpgradesManager.UpdateFromSavedData(SvgData.upgrades); //TEST #if UNITY_EDITOR print("Savegame read from PlayerPrefs: Current scene name = " + SvgData.currentSceneName + " | Checkpoint ID = " + SvgData.currCheckpointID); //TEST DisplayUnserializedDEBUG(); //TEST #endif } else { print("No savegame => creating a new SvgData in memory and using Upgrades.List currently in memory."); //TEST generateNewSvgData(); //As there is no savegame we create a new SvgData (and we fill its upgrades member with Upgrades.List) } } }