public void SetSelected(UIButtonInGame button) { foreach (UIButtonInGame thisButton in container.gameObject.GetComponentsInChildren <UIButtonInGame>()) { if (thisButton != button) { thisButton.SetSelected(false); } else { thisButton.SetSelected(true); Events.SetScriptSelected(thisButton.script); } } }
void RefreshButtons() { Utils.RemoveAllChildsIn(container); foreach (AmiScript amiScript in CharacterData.Instance.characterScripts.scripts) { UIButtonInGame newButton = Instantiate(buttonInGame); newButton.transform.SetParent(container); newButton.transform.localScale = Vector3.one; newButton.Init(this, amiScript); } UIButtonInGame[] buttons = container.gameObject.GetComponentsInChildren <UIButtonInGame> (); if (buttons.Length > 0) { SetSelected(buttons [buttons.Length - 1]); } }