123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class UIWFTabPanel : MonoBehaviour
- {
- public void Start()
- {
- if (this.onclick_event_ != null)
- {
- return;
- }
- this.UpdateChildren();
- }
- public void AddChildrenList(List<UIWFTabButton> button_list)
- {
- if (!base.enabled)
- {
- return;
- }
- if (this.onclick_event_ == null)
- {
- this.onclick_event_ = new EventDelegate(this, "OnClick");
- }
- this.button_list_.Clear();
- for (int i = 0; i < button_list.Count; i++)
- {
- UIWFTabButton uiwftabButton = this.button_list_[i];
- if (uiwftabButton != null)
- {
- bool flag = false;
- for (int j = 0; j < uiwftabButton.onClick.Count; j++)
- {
- if (uiwftabButton.onClick[j] == this.onclick_event_)
- {
- flag = true;
- break;
- }
- }
- if (!flag)
- {
- uiwftabButton.onClick.Add(this.onclick_event_);
- }
- }
- }
- }
- public void UpdateChildren()
- {
- if (!base.enabled)
- {
- return;
- }
- if (this.onclick_event_ == null)
- {
- this.onclick_event_ = new EventDelegate(this, "OnClick");
- }
- this.button_list_.Clear();
- Transform transform = base.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- if (transform.gameObject.activeSelf)
- {
- UIWFTabButton componentInChildren = transform.GetChild(i).GetComponentInChildren<UIWFTabButton>();
- if (componentInChildren != null)
- {
- this.button_list_.Add(componentInChildren);
- bool flag = false;
- for (int j = 0; j < componentInChildren.onClick.Count; j++)
- {
- if (componentInChildren.onClick[j] == this.onclick_event_)
- {
- flag = true;
- break;
- }
- }
- if (!flag)
- {
- componentInChildren.onClick.Add(this.onclick_event_);
- }
- }
- }
- }
- }
- public void Select(UIWFTabButton button)
- {
- if (!base.enabled)
- {
- return;
- }
- UIWFTabButton current = UIWFTabButton.current;
- UIButton current2 = UIButton.current;
- UIWFTabButton.current = button;
- UIButton.current = button;
- EventDelegate.Execute(button.onClick);
- UIWFTabButton.current = current;
- UIButton.current = current2;
- }
- public void ResetSelect()
- {
- this.select_button_ = null;
- }
- public UIWFTabButton GetSelectButtonObject()
- {
- return this.select_button_;
- }
- private void OnClick()
- {
- if (!base.enabled)
- {
- return;
- }
- for (int i = 0; i < this.button_list_.Count; i++)
- {
- if (this.button_list_[i].enabled)
- {
- bool flag = UIButton.current == this.button_list_[i];
- if (flag)
- {
- this.select_button_ = this.button_list_[i];
- }
- this.button_list_[i].SetSelect(flag);
- }
- }
- }
- public List<UIWFTabButton> button_list
- {
- get
- {
- return this.button_list_;
- }
- }
- private List<UIWFTabButton> button_list_ = new List<UIWFTabButton>();
- private EventDelegate onclick_event_;
- private HashSet<int> event_add_object_hash_list_ = new HashSet<int>();
- private UIWFTabButton select_button_;
- }
|