public void Save2() { BinaryFormatter binary = new BinaryFormatter(); FileStream file = File.Create(Application.dataPath + "/Savegame2.dat"); SaveManagment2 save2 = new SaveManagment2(); save2.HScore = GetComponent <SavedData>().HScore; save2.scoreValue = GetComponent <SavedData>().scoreValue; binary.Serialize(file, save2); file.Close(); }
public void Load2() { if (File.Exists(Application.dataPath + "/Savegame2.dat")) { BinaryFormatter binary = new BinaryFormatter(); FileStream file = File.Open(Application.dataPath + "/Savegame2.dat", FileMode.Open); SaveManagment2 save2 = (SaveManagment2)binary.Deserialize(file); GetComponent <MenuGameEnd>().HighScore = save2.HScore; GetComponent <MenuGameEnd>().Score = save2.scoreValue; file.Close(); } }