public void OnTabSelected(TabButton button) { if (selectedTab != null && selectedTab != button) { selectedTab.Deselected(); } if (selectedTab == button && button.active) { button.Deselected(); selectedTab = null; } else { selectedTab = button; selectedTab.Selected(); ResetTabs(); button.background.sprite = tabActive; int index = button.transform.GetSiblingIndex(); for (int i = 0; i < objectsToSwap.Count; ++i) { if (i == index) { objectsToSwap[i].SetActive(true); } else { objectsToSwap[i].SetActive(false); } } } }