void RefreshScores(List <ScoreOutput> sortedCurrentScores) { foreach (RectTransform child in scoreEntriesContainer) { Destroy(child.gameObject); } foreach (ScoreOutput scoreOutput in sortedCurrentScores) { ScoreEntryUI scoreEntry = Instantiate(scoreEntryPrefab, scoreEntriesContainer); scoreEntry.SetData(scoreOutput.name, scoreOutput.elapsedTime); } }
private void UpdateUI(ScoreboardSaveData savedScores, ScoreEntryData newData) { if (savedScores.highScores.Count == 0) { //Disable the highscores holder scoreHolder.gameObject.SetActive(false); return; } //If the holder game object is disabled if (scoreHolder.gameObject.activeSelf == false) { //Activate the game object scoreHolder.gameObject.SetActive(true); } //Loop through all child objects in scoreHoler foreach (Transform child in scoreHolder) { //Destroy the child object Destroy(child.gameObject); } //Loop through all the entries in savedScores foreach (ScoreEntryData highScore in savedScores.highScores) { //Spawn the entry UI ScoreEntryUI scoreListing = Instantiate(scoreEntryObject, scoreHolder).GetComponent <ScoreEntryUI>(); //Initalise the UI scoreListing.Initialize(highScore); //check if the new data matches the current highscore if (newData.Equals(highScore)) { scoreListing.HighlightUI(); } } }