// == gets/sets == private void Awake() { entryContainer = transform.Find("ScoreContainer"); entryTemplate = entryContainer.Find("ScoreEntry"); entryTemplate.gameObject.SetActive(false); // load high scores from data highScoreList = SaveSystem.LoadHighScores(); if (highScoreList != null) { //highScoreEntryList = new List<HighScoreEntry>(); highScoreEntryList = highScoreList.getHighScoreList(); } else { // initalise new list with sample data (only happens when program is first run) highScoreEntryList = new List <HighScoreEntry>() { new HighScoreEntry(2500, "KAT"), new HighScoreEntry(3500, "KEN"), new HighScoreEntry(4000, "SAM"), new HighScoreEntry(4500, "JOE"), new HighScoreEntry(5000, "BOB") }; // save score data SaveSystem.SaveHighScores(highScoreEntryList); } // sort list in descending order for (int i = 0; i < highScoreEntryList.Count; i++) { for (int j = i + 1; j < highScoreEntryList.Count; j++) { if (highScoreEntryList[j].score > highScoreEntryList[i].score) { // swap scores HighScoreEntry temp = highScoreEntryList[i]; highScoreEntryList[i] = highScoreEntryList[j]; highScoreEntryList[j] = temp; } } } // create a list of scores and display them in a table highScoreEntryTransformList = new List <Transform>(); foreach (HighScoreEntry highScoreEntry in highScoreEntryList) { CreateHighScoreTransform(highScoreEntry, entryContainer, highScoreEntryTransformList); } }