using System; using System.Collections.Generic; using UnityEngine; public class uGUITabPanel : MonoBehaviour { public List buttonList { get { return this.m_buttonList; } } public void Start() { if (this.onClickEvent != null) { return; } this.UpdateChildren(); } public void AddChildrenList(List buttonList) { if (!base.enabled) { return; } if (this.onClickEvent == null) { this.onClickEvent = new EventDelegate(this, "OnClick"); } this.m_buttonList.Clear(); for (int i = 0; i < buttonList.Count; i++) { uGUITabButton uGUITabButton = this.m_buttonList[i]; if (uGUITabButton != null) { bool flag = false; for (int j = 0; j < uGUITabButton.onClickEvent.Count; j++) { if (uGUITabButton.onClickEvent[j] == this.onClickEvent) { flag = true; break; } } if (!flag) { uGUITabButton.onClickEvent.Add(this.onClickEvent); } } } } public void UpdateChildren() { if (!base.enabled) { return; } if (this.onClickEvent == null) { this.onClickEvent = new EventDelegate(this, "OnClick"); } this.m_buttonList.Clear(); Transform transform = base.transform; for (int i = 0; i < transform.childCount; i++) { if (transform.gameObject.activeSelf) { uGUITabButton componentInChildren = transform.GetChild(i).GetComponentInChildren(); if (componentInChildren != null) { this.m_buttonList.Add(componentInChildren); bool flag = false; for (int j = 0; j < componentInChildren.onClickEvent.Count; j++) { if (componentInChildren.onClickEvent[j] == this.onClickEvent) { flag = true; break; } } if (!flag) { componentInChildren.onClickEvent.Add(this.onClickEvent); } } } } } public void Select(uGUITabButton button) { if (!base.enabled) { return; } uGUITabButton current = uGUITabButton.current; uGUITabButton.current = button; EventDelegate.Execute(button.onClickEvent); uGUITabButton.current = current; } public void ResetSelect() { this.selectButton = null; } public uGUITabButton GetSelectButton() { return this.selectButton; } private void OnClick() { if (!base.enabled) { return; } for (int i = 0; i < this.m_buttonList.Count; i++) { if (this.m_buttonList[i].enabled) { bool flag = uGUITabButton.current == this.m_buttonList[i]; if (flag) { this.selectButton = this.m_buttonList[i]; } this.m_buttonList[i].SetSelect(flag); } } } private EventDelegate onClickEvent; private List m_buttonList = new List(); private uGUITabButton selectButton; }