public HighScoreEntry AddHighScoreToSong(string songHash, string userName, string difficulty, string playingMethod, long score) { if (!string.IsNullOrWhiteSpace(userName) && score > 0) { if (!Directory.Exists(Path.Combine(highScorePath, songHash))) { Directory.CreateDirectory(Path.Combine(highScorePath, songHash)); } var scorePath = GetScorePath(songHash, difficulty, playingMethod); var existingHighScores = GetHighScoreOfSong(scorePath); var entry = new HighScoreEntry { Username = userName, Score = score, Time = DateTime.Now.ToFileTimeUtc() }; existingHighScores.Add(entry); File.WriteAllText(scorePath, JsonUtility.ToJson(HighScores.Create(existingHighScores))); return(entry); } else { return(null); } }