public void ReseteSaveFile() { if (File.Exists(Application.persistentDataPath + "/gamesave.save")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open); Save save = (Save)bf.Deserialize(file); file.Close(); //Aqui se hace lo contrario que en el CreateSaveGameObject. Se toman las variables del save y se aplican esos valores a las variables que se usan en código currentExp = 0; lastLevelWon = 0; characterDataForCurrentLevel.Clear(); allLevelNodes = FindObjectsOfType <LevelNode>(); for (int i = 0; i < allLevelNodes.Length; i++) { allLevelNodes[i].HideThisLevel(); } levelIDsUnlocked.Clear(); for (int i = 0; i < allLevelNodes.Length; i++) { if (allLevelNodes[i].idLevel == 1) { levelIDsUnlocked.Add(allLevelNodes[i].idLevel); allLevelNodes[i].UnlockThisLevel(); } } #region Characters KnightData _knight = FindObjectOfType <KnightData>(); _knight.unitPowerLevel = _knight.initialPowerLevelOnlyUsedForResetSaveFile; _knight.HideShowMeshCharacterData(true); _knight.isCharacterUnlocked = true; _knight.idSkillsBought.Clear(); MageData _mage = FindObjectOfType <MageData>(); _mage.unitPowerLevel = _mage.initialPowerLevelOnlyUsedForResetSaveFile; _mage.HideShowMeshCharacterData(true); _mage.isCharacterUnlocked = true; _mage.idSkillsBought.Clear(); //Añado al mago y al caballero para que salgan en la caja de selección al principio characterDataForCurrentLevel.Add(_knight); characterDataForCurrentLevel.Add(_mage); RogueData _rogue = FindObjectOfType <RogueData>(); _rogue.unitPowerLevel = _rogue.initialPowerLevelOnlyUsedForResetSaveFile; _rogue.HideShowMeshCharacterData(false); _rogue.isCharacterUnlocked = false; _rogue.idSkillsBought.Clear(); BerserkerData _berserker = FindObjectOfType <BerserkerData>(); _berserker.unitPowerLevel = _berserker.initialPowerLevelOnlyUsedForResetSaveFile; _berserker.HideShowMeshCharacterData(false); _berserker.isCharacterUnlocked = false; _berserker.idSkillsBought.Clear(); ValkyrieData _valkyrie = FindObjectOfType <ValkyrieData>(); _valkyrie.unitPowerLevel = _valkyrie.initialPowerLevelOnlyUsedForResetSaveFile; _valkyrie.HideShowMeshCharacterData(false); _valkyrie.isCharacterUnlocked = false; _valkyrie.idSkillsBought.Clear(); DruidData _druid = FindObjectOfType <DruidData>(); _druid.unitPowerLevel = _druid.initialPowerLevelOnlyUsedForResetSaveFile; _druid.HideShowMeshCharacterData(false); _druid.isCharacterUnlocked = false; _druid.idSkillsBought.Clear(); MonkData _monk = FindObjectOfType <MonkData>(); _monk.unitPowerLevel = _monk.initialPowerLevelOnlyUsedForResetSaveFile; _monk.HideShowMeshCharacterData(false); _monk.isCharacterUnlocked = false; _monk.idSkillsBought.Clear(); SamuraiData _samurai = FindObjectOfType <SamuraiData>(); _samurai.unitPowerLevel = _samurai.initialPowerLevelOnlyUsedForResetSaveFile; _samurai.HideShowMeshCharacterData(false); _samurai.isCharacterUnlocked = false; _samurai.idSkillsBought.Clear(); #endregion enemiesKilled = 0; randomLevelsCompleted = 0; Debug.Log("File Reseted"); Debug.Log("-----"); } else { Debug.Log("Se ha intentado cargar y no existe archivo de guardado"); } print(Application.persistentDataPath); }