You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
1 month ago
|
using System;
|
||
|
using TMPro;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.EventSystems;
|
||
|
|
||
|
namespace WalletConnectUnity.UI
|
||
|
{
|
||
|
public class WCTabButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||
|
{
|
||
|
[SerializeField] private RectTransform _rootTransform;
|
||
|
[SerializeField] private TMP_Text _label;
|
||
|
[SerializeField] private Color _normalColor;
|
||
|
[SerializeField] private Color _hoverColor;
|
||
|
[SerializeField] private Color _selectedColor;
|
||
|
|
||
|
private bool _isSelected;
|
||
|
|
||
|
public event EventHandler Clicked;
|
||
|
|
||
|
public RectTransform RootTransform => _rootTransform;
|
||
|
public TMP_Text Label => _label;
|
||
|
|
||
|
public bool IsVisible => gameObject.activeSelf;
|
||
|
|
||
|
public void OnPointerEnter(PointerEventData eventData)
|
||
|
{
|
||
|
_label.color = _hoverColor;
|
||
|
}
|
||
|
|
||
|
public void OnPointerExit(PointerEventData eventData)
|
||
|
{
|
||
|
_label.color = _isSelected ? _selectedColor : _normalColor;
|
||
|
}
|
||
|
|
||
|
public void OnPointerClick(PointerEventData eventData)
|
||
|
{
|
||
|
Clicked?.Invoke(this, EventArgs.Empty);
|
||
|
}
|
||
|
|
||
|
public void Select()
|
||
|
{
|
||
|
_isSelected = true;
|
||
|
_label.color = _selectedColor;
|
||
|
}
|
||
|
|
||
|
public void Deselect()
|
||
|
{
|
||
|
_isSelected = false;
|
||
|
_label.color = _normalColor;
|
||
|
}
|
||
|
|
||
|
public void Show() => gameObject.SetActive(true);
|
||
|
|
||
|
public void Hide() => gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|