public void Populate() { if (InputManager.PlayerCount <= 0) { return; } selectionMenus.Clear(); CharacterManager.Clear(); // Instantiate menus foreach (var player in InputManager.AssignedPlayers) { var selectionMenu = Instantiate(creationMenuPrefab, transform); selectionMenu.name = "CharacterCreationMenu" + player; selectionMenu.Initialize(player); selectionMenu.Menu.OnOpened.AddListener(() => { InputManager.SetActivePlayer(player); }); selectionMenu.gameObject.SetActive(false); selectionMenus.Add(selectionMenu); } // Link menu navigation for (var i = 0; i < selectionMenus.Count - 1; i++) { var nextMenu = selectionMenus[i + 1].Menu; selectionMenus[i].DoneButton.onClick.AddListener(() => { menuGroup.ChangeMenu(nextMenu); }); } // Set last menu to trigger Finish method selectionMenus[selectionMenus.Count - 1].DoneButton.onClick.AddListener(Finish); // Set first menu as active menuGroup.RefreshMenuList(); menuGroup.ChangeMenu(selectionMenus[0].Menu); }