using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class uGUITabButton : Button { public bool isSelected { get { return this.selected_; } } public bool isEnabled { get { return base.enabled; } set { base.enabled = value; } } protected void OnInit() { this.isInit = true; this.backupDefaultColor = base.targetGraphic.color; this.isInitColor = true; if (this.selectSprite != null) { if (!this.selectSprite.enabled) { this.selectSprite.enabled = true; } this.selectSprite.color = new Color(this.selectSprite.color.r, this.selectSprite.color.g, this.selectSprite.color.b, 0f); } } public override void OnPointerClick(PointerEventData eventData) { if (uGUITabButton.current == null && base.enabled && base.interactable) { base.OnPointerClick(eventData); uGUITabButton.current = this; EventDelegate.Execute(this.onClickEvent); uGUITabButton.current = null; } } public void SetSelect(bool is_select) { if (!this.isInit) { this.OnInit(); } if (!this.isInitColor) { this.backupDefaultColor = base.targetGraphic.color; this.isInitColor = true; } this.selected_ = is_select; if (is_select) { base.targetGraphic.color = base.colors.normalColor; if (this.selectSprite != null) { this.selectSprite.color = new Color(this.selectSprite.color.r, this.selectSprite.color.g, this.selectSprite.color.b, 1f); } uGUISelectableAnimation component = base.GetComponent(); if (component != null) { component.enabled = false; } if (this.maskObj != null) { this.maskObj.SetActive(true); } uGUITabButton uGUITabButton = uGUITabButton.current; uGUITabButton.current = this; uGUITabButton.selected = is_select; EventDelegate.Execute(this.onSelectEvent); uGUITabButton.selected = false; uGUITabButton.current = uGUITabButton; } else { base.targetGraphic.color = this.backupDefaultColor; if (this.selectSprite != null) { this.selectSprite.color = new Color(this.selectSprite.color.r, this.selectSprite.color.g, this.selectSprite.color.b, 0f); } uGUISelectableAnimation component2 = base.GetComponent(); if (component2 != null) { component2.enabled = true; } if (this.maskObj != null) { this.maskObj.SetActive(false); } } } public List onClickEvent = new List(); public List onSelectEvent = new List(); public Image selectSprite; public GameObject maskObj; protected bool selected_; public static bool selected; public static uGUITabButton current; private bool isInit; private bool isInitColor; protected Color backupDefaultColor; }