void setupPageButton(ToggleableColorUIButton pageButton, int pageIndex) { pageButton.SubscribeToClick(delegate() { parentWindow.SwitchToPage(pageIndex, onClickPageButton: true); }); pageButton.SetToggleOnClickEnabled(isEnabled: false); }
public void SwitchToPage(int pageIndex, bool onClickPageButton) { checkReferences(); if (HasSelectedPage) { // Turn off the last page button selectedPageButton.Toggle(); } selectedPageButton = pageButtons[pageIndex]; if (!onClickPageButton) { selectedPageButton.Toggle(); } }
// There are extra steps that do not need to be performed on init ToggleableColorUIButton addPageButton(int pageIndex, bool addingOnInit) { GameObject buttonobject = Instantiate(pageButtonRef, pageButtonParent); buttonobject.SetActive(true); ToggleableColorUIButton pageButton = buttonobject.GetComponent <ToggleableColorUIButton>(); if (!addingOnInit) { setupPageButton(pageButton, pageIndex); refreshPageButtonReferences(); } return(pageButton); }