void OnItemClick(object sender, EventArgs e) { SelectedItem = sender as SaveItem; if (ChangeSelectedItemHandler != null) { ChangeSelectedItemHandler(this, null); } }
void UpdateSaveList() { int currentScrollCount = scrollView.content.childCount; string[] saves = SaveManager.Instance.GetSaves(); //Hide old for (int i = saves.Length; i < currentScrollCount; i++) { list[i].gameObject.SetActive(false); list[i].ClickHandler -= OnItemClick; } //Create new for (int i = currentScrollCount; i < saves.Length; i++) { SaveItem listItem = GameObject.Instantiate(saveItem, scrollView.content.transform); list.Add(listItem); } //Set text for (int i = 0; i < saves.Length; i++) { list[i].Text = saves[i]; list[i].ClickHandler += OnItemClick; } }