private void DeselectCurrentItem() { if (selected != null) // Is there a selected item currently? { selected.GetComponent <Image>().sprite = outlineUnselectedSprite; selected = null; } }
IEnumerator pickDefault() { yield return(null); EventSystem.current.SetSelectedGameObject(null); yield return(null); EventSystem.current.SetSelectedGameObject(defaultItem.gameObject); yield return(null); defaultItem.GetComponent <Button>().Select(); }
public void SelectItem(LevelSelectItem item) { if (item != selected) { DeselectCurrentItem(); // Update selected item selected = item; selected.GetComponent <Image>().sprite = outlineSelectedSprite; // Update overview board overviewName.text = item.levelName; // Update best time int time = PlayerPrefs.GetInt("best-time-level" + item.levelIndex, -1); if (time != -1) { string minutes = (time / 60).ToString(); string seconds = (time % 60).ToString("00"); overviewTime.text = string.Format("{0}:{1}", minutes, seconds); // Update timer count. } else { overviewTime.text = "--"; } // Update high score int score = PlayerPrefs.GetInt("high-score-level" + item.levelIndex, -1); if (score != -1) { overviewScore.text = score.ToString(); } else { overviewScore.text = "--"; } overview.SetActive(true); // Play selection sound asource.Play(); } }