public void SaveScore(IOScoreModel score) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + scoreFileName, FileMode.Open); bf.Serialize(file, score); file.Close(); }
public IOScoreModel LoadScore() { if (File.Exists(Application.persistentDataPath + scoreFileName)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + scoreFileName, FileMode.Open); IOScoreModel score = (IOScoreModel)bf.Deserialize(file); file.Close(); return(score); } return(new IOScoreModel()); }