1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using System;
- public class TabButton
- {
- protected GameObject m_GameObject;
- protected bool m_Selected;
- protected bool m_Disabled;
- protected TabButtonGroup m_Group;
- public GameObject GameObject
- {
- get
- {
- return this.m_GameObject;
- }
- set
- {
- this.m_GameObject = value;
- this.Init();
- }
- }
- public bool Selected
- {
- get
- {
- return this.m_Selected;
- }
- set
- {
- if (this.m_Disabled)
- {
- return;
- }
- this.m_Selected = value;
- this.Render();
- }
- }
- public bool Disabled
- {
- get
- {
- return this.m_Disabled;
- }
- set
- {
- this.m_Disabled = value;
- this.Render();
- }
- }
- public TabButton(TabButtonGroup group)
- {
- this.m_Group = group;
- this.m_Group.Add(this);
- }
- public void Select()
- {
- if (this.m_Disabled)
- {
- return;
- }
- if (this.m_Selected)
- {
- return;
- }
- this.m_Group.Select(this);
- }
- public void OnDestroy()
- {
- this.m_Group.Remove(this);
- this.m_Group = null;
- }
- protected virtual void Init()
- {
- ClickEventTriggerListener.Get(this.m_GameObject).onPointerDown = new ClickEventTriggerListener.PointDelegate(this.OnDown);
- ClickEventTriggerListener.Get(this.m_GameObject).onPointerUp = new ClickEventTriggerListener.PointDelegate(this.OnUp);
- ClickEventTriggerListener.Get(this.m_GameObject).onPointerClick = new ClickEventTriggerListener.PointDelegate(this.OnClick);
- }
- protected virtual void OnDown(PointerEventData eventData)
- {
- }
- protected virtual void OnUp(PointerEventData eventData)
- {
- }
- protected virtual void OnClick(PointerEventData eventData)
- {
- this.Select();
- }
- protected virtual void Render()
- {
- }
- }
|