Example #1
0
        public void Refresh()
        {
            matchInfo = Data.Database.Mediator.Match.MatchInfo.Invalid; // Invalidate our selected match
            while (buttons.Count > 0)                                   // Clear all existing buttons.
            {
                Button button = buttons.Dequeue();
                button.onClick.RemoveAllListeners();
                Destroy(button.gameObject);
            }

            Data.Database.Mediator.Match match = menuSystem.uiSystem.systemMediator.dataSystem.databaseSystem.match;
            content.sizeDelta = new Vector2(0, button.GetComponent <RectTransform>().rect.height *match.Count()); // Resize contents
            for (int i = 0; i < match.Count(); i++)
            {
                Button matchButton = Instantiate(button, buttonParent).GetComponent <Button>();
                buttons.Enqueue(matchButton);
                matchButton.GetComponentInChildren <Text>().text = match[i].name + "'s Game";
                int x = i;
                matchButton.onClick.AddListener(() => ButtonClicked(x));
            }
        }
Example #2
0
 private void ButtonClicked(int index)
 {
     Data.Database.Mediator.Match match = menuSystem.uiSystem.systemMediator.dataSystem.databaseSystem.match;
     matchInfo = match[index];
 }