void Awake() { if (Instance == null) { DontDestroyOnLoad(gameObject); Instance = this; var descendingComparer = Comparer <float> .Create((x, y) => y.CompareTo(x)); pastScores = new SortedList <float, string>(descendingComparer); readLeaderboardFromFile(); // uncomment either one of these to pre-fill the leaderboard with scores // initializePlaceHolderScores(); // initializeLargePlaceHolderScores(); } else if (Instance != this) { Destroy(gameObject); } }
void addNewScore(float time, string username) { localPastScores.Add(time, username); localNumOfLeaderboardPlayers = localPastScores.Count < maxNumOfLeaderboard ? localPastScores.Count : maxNumOfLeaderboard; GlobalControl.updateLeaderBoard(localPastScores, localNumOfLeaderboardPlayers); }