public void FillScoreBoard() { if (scoreRows != null) { foreach (GameObject srow in scoreRows) { Destroy(srow); } } float rowHeight = scoreRowPrefab.GetComponent <RectTransform>().sizeDelta.y; foreach ((string name, int score, int index) in scoreboardManager.GreatestResults()) { GameObject row = Instantiate(scoreRowPrefab, scoreTable.transform); row.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -137 - rowHeight * index); row.transform.GetChild(0).GetComponent <Text>().text = name; row.transform.GetChild(1).GetComponent <Text>().text = score.ToString(); scoreRows.Add(row); } }