IEnumerator CreateRoundButtons() { // Starts from the right int counter = 0; while (counter < buttonTypesList.Count) { UIManager_v5.RoundButtonType type = buttonTypesList[counter]; TopBarRoundButton newButton = uiManager.GetTopBarRoundButton(selectedComponent, type); newButton.transform.SetParent(displaySelectedPanel.transform, false); newButton.gameObject.SetActive(true); Rect newButtonRect = newButton.button.image.rectTransform.rect; newButton.button.image.rectTransform.anchoredPosition = new Vector2(((newButtonRect.width + newButtonRect.width / 2) * counter), newButtonRect.height + newButtonRect.height / 2); switch (type) { case UIManager_v5.RoundButtonType.componentActions: newButton.button.onClick.AddListener(() => DisplaySelectedComponentActionsToggle()); break; } newButton.OnScreen(); currentRoundButtons.Add(newButton); yield return(new WaitForSeconds(.15f)); counter++; } buttonCount = buttonTypesList.Count; }
public TopBarRoundButton GetTopBarRoundButton(string component, RoundButtonType buttonType) { TopBarRoundButton toReturn = null; switch (buttonType) { case RoundButtonType.componentActions: toReturn = Instantiate(topBarRoundButtonPrefab); break; default: toReturn = Instantiate(topBarRoundButtonPrefab); break; } return(toReturn); }