using System; using UnityEngine; using UnityEngine.EventSystems; namespace SanAndreasUnity.Utilities { public class UIEventsPickup : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler, IDragHandler { public event Action onPointerClick = delegate {}; public event Action onPointerEnter = delegate {}; public event Action onPointerExit = delegate {}; public event Action onPointerDown = delegate {}; public event Action onPointerUp = delegate {}; public event Action onDrag = delegate {}; public bool IsPointerInside { get; private set; } = false; public bool IsPointerDown { get; private set; } = false; void OnDisable() { this.IsPointerInside = false; this.IsPointerDown = false; } public void OnPointerClick (PointerEventData eventData) { onPointerClick (eventData); } public void OnPointerEnter (PointerEventData eventData) { this.IsPointerInside = true; onPointerEnter (eventData); } public void OnPointerExit (PointerEventData eventData) { this.IsPointerInside = false; onPointerExit (eventData); } public void OnPointerDown (PointerEventData eventData) { this.IsPointerDown = true; onPointerDown (eventData); } public void OnPointerUp (PointerEventData eventData) { this.IsPointerDown = false; onPointerUp (eventData); } public void OnDrag (PointerEventData eventData) { onDrag (eventData); } } }