WinterJamSnowman/Assets/Scripts/LemonGenericLib/UI/Tabs/TabButtonScript.cs

67 lines
1.3 KiB
C#
Raw Permalink Normal View History

2023-01-24 13:51:46 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
namespace Lemon.GenericLib.UI
{
public class TabButtonScript : MonoBehaviour, IPointerEnterHandler, IPointerClickHandler, IPointerExitHandler
{
[SerializeField] TabGroup tabGroup;
[SerializeField] private UnityEvent onTabEnter;
[SerializeField] private UnityEvent onTabExit;
[SerializeField] private UnityEvent onTabSelected;
[SerializeField] private UnityEvent onTabDeselected;
public void OnPointerClick(PointerEventData eventData)
{
tabGroup.OnTabSelected(this);
}
public void OnPointerEnter(PointerEventData eventData)
{
tabGroup.OnTabEnter(this);
}
public void OnPointerExit(PointerEventData eventData)
{
tabGroup.OnTabExit(this);
}
public void OnEnter()
{
onTabEnter?.Invoke();
}
public void OnExit()
{
onTabExit?.Invoke();
}
public void OnSelected()
{
onTabSelected?.Invoke();
}
public void OnDeselected()
{
onTabDeselected?.Invoke();
}
}
}