private IEnumerator EnsureJoinedMatchExistsRoutine(Data.Database.Mediator.Match.MatchInfo matchInfo)
        {
            Database.Mediator.Match match         = dataSystem.databaseSystem.match;
            NetworkSystem           networkSystem = dataSystem.networkSystem;

            while (true)
            {
                if (!match.Exists(matchInfo))
                {
                    networkSystem.StopModule();
                    dataSystem.systemMediator.uiSystem.menuSystem.BackUntil(DisconnectedMenu);
                    break;
                }
                yield return(null);
            }
        }
        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));
            }
        }
 private void ButtonClicked(int index)
 {
     Data.Database.Mediator.Match match = menuSystem.uiSystem.systemMediator.dataSystem.databaseSystem.match;
     matchInfo = match[index];
 }