public static void AddNewEntry(int score) { newEntry = new HighscoresEntry() { score = score }; }
void CreateEntry(HighscoresEntry entry, Transform container, List <Transform> transformList) { Transform entryTransform = Instantiate(entriesPrefab, container); RectTransform entryRectTransform = entryTransform.GetComponent <RectTransform>(); entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * transformList.Count); int rank = transformList.Count + 1; string rankString; switch (rank) { case 1: rankString = "1st"; break; case 2: rankString = "2nd"; break; case 3: rankString = "3rd"; break; default: rankString = rank + "th"; break; } entryTransform.Find("PosText").GetComponent <Text>().text = rankString; Image bg = entryTransform.GetComponent <Image>(); Color color = bg.color; color.a = rank % 2 == 0 ? 0 : 0.2f; bg.color = color; entryTransform.Find("ScoreText").GetComponent <Text>().text = entry.score.ToString(); if (entry == newEntry) { entryTransform.Find("NameInput").gameObject.SetActive(true); } entryTransform.Find("NameText").GetComponent <Text>().text = entry.name; transformList.Add(entryTransform); }
public void DontKeepScore() { newEntry = null; SceneManager.LoadScene(0); }
public void KeepScore() { Save(); newEntry = null; SceneManager.LoadScene(0); }