123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class uGUITabPanel : MonoBehaviour
- {
- public List<uGUITabButton> buttonList
- {
- get
- {
- return this.m_buttonList;
- }
- }
- public void Start()
- {
- if (this.onClickEvent != null)
- {
- return;
- }
- this.UpdateChildren();
- }
- public void AddChildrenList(List<uGUITabButton> 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<uGUITabButton>();
- 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<uGUITabButton> m_buttonList = new List<uGUITabButton>();
- private uGUITabButton selectButton;
- }
|