public static void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/" + filename); Maze_Data data = new Maze_Data(); data.Highscore = highscore; data.CurrentScore = currentscore; data.Level = level; data.Isreturn = isreturn; data.AdsFrequency = adsFrequency; bf.Serialize(file, data); file.Close(); }
public static void Load() { if (File.Exists(Application.persistentDataPath + "/" + filename)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/" + filename, FileMode.Open); Maze_Data data = (Maze_Data)bf.Deserialize(file); highscore = data.Highscore; currentscore = data.CurrentScore; level = data.Level; isreturn = data.Isreturn; adsFrequency = data.AdsFrequency; file.Close(); } else { mazesaveload.Save(); } }