// Write the current score to the high score list stored in the persistentDataPath public static void SaveScore(string currentSong, string playerName, int score, int maxCombo, int hits, int misses) { BinaryFormatter bf = new BinaryFormatter(); //HighScoreList highScores = null; if (File.Exists(_savePath)) { file = new FileStream(_savePath, FileMode.Open); // if(file.Length != 0){ HighScores = bf.Deserialize(file) as HighScoreList; // } } //Debug.Log("(!File.Exists(_savePath) || file.Length == 0): " + (!File.Exists(_savePath) || file.Length == 0)); // if(!File.Exists(_savePath) || file.Length == 0) else { file = new FileStream(_savePath, FileMode.Create); HighScores = new HighScoreList(); } //Debug.Log(_savePath); // Debug.Log("Pre add: highScores.scoreList.Count: " + highScores.scoreList.Count); //Debug.Log("Pre Add: " + HighScores.ToString()); // TODO: Player profile HighScores.AddNewScore(currentSong, playerName, score, maxCombo, hits, misses); //Debug.Log("Post Add: " + HighScores.ToString()); // Debug.Log("Post add: highScores.scoreList.Count: " + highScores.scoreList.Count); bf.Serialize(file, HighScores); //HighScores = (HighScoreList)bf.Deserialize(file); //Debug.Log("Immediately Deserialized: " + HighScores.ToString()); file.Close(); // file = File.Open(_savePath, FileMode.Open); // highScores = (HighScoreList)bf.Deserialize(file); // Debug.Log("Closed and reopened: " + highScores.ToString()); // // Debug.Log("End step: highScores.scoreList.Count: " + highScores.scoreList.Count); // file.Close(); }