StationObscurum/Assets/Packages/Heat - Complete Modern UI/Scripts/Events/PointerEvent.cs

22 lines
899 B
C#
Raw Normal View History

2024-02-02 04:45:59 +01:00
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace Michsky.UI.Heat
{
public class PointerEvent : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
[Header("Settings")]
public bool addEventTrigger = true;
[Header("Events")]
[SerializeField] private UnityEvent onClick = new UnityEvent();
[SerializeField] private UnityEvent onEnter = new UnityEvent();
[SerializeField] private UnityEvent onExit = new UnityEvent();
void Awake() { if (addEventTrigger == true) { gameObject.AddComponent<EventTrigger>(); } }
public void OnPointerClick(PointerEventData eventData) { onClick.Invoke(); }
public void OnPointerEnter(PointerEventData eventData) { onEnter.Invoke(); }
public void OnPointerExit(PointerEventData eventData) { onExit.Invoke(); }
}
}