public void refreshTabs() { iNwkUiTab[] _refTabs = fetchTabs(); //Debug.Log("found " + _refTabs.Length + " tabs"); for (int i = 0; i < _refTabs.Length; i++) { NwkUiTab _tab = null; if (tabs.Count > i) { _tab = tabs[i]; } if (_tab == null) { _tab = new NwkUiTab(); tabs.Add(_tab); } _tab.tabRef = _refTabs[i]; if (_tab.tabButton == null) { _tab.tabButton = GameObject.Instantiate(refTabButton).GetComponentInChildren <Button>(); _tab.tabButton.gameObject.SetActive(true); // ref is disabled //Debug.Log("created " + _tab.tabButton, _tab.tabButton); } //part of the tab group _tab.tabButton.transform.SetParent(refTabButton.transform.parent); Text label = _tab.tabButton.GetComponentInChildren <Text>(); label.text = _tab.tabRef.getTabLabel(); } //Debug.Log(tabs.Count + " > " + _refTabs.Length); while (tabs.Count > _refTabs.Length) { tabs[tabs.Count - 1].destroy(); tabs.RemoveAt(tabs.Count - 1); } }
public void tabButtonPress(Button clickedButton) { //Debug.Log(clickedButton.name); for (int i = 0; i < tabs.Count; i++) { NwkUiTab tab = getTabRefByName(tabs[i].tabButton.GetComponentInChildren <Text>().text); //Debug.Log(tab.tabRef); if (tabs[i].tabButton == clickedButton) { tab.tabRef.toggleTab(); } else { tab.tabRef.hideTab(); } } }