PointerHandler.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using UnityEngine.Events;
  2. using UnityEngine.EventSystems;
  3. using UnityEngine;
  4. [AddComponentMenu("SDK/PointerHandler")]
  5. public class PointerHandler : MonoBehaviour, IPointerHandler {
  6. public PointerUnityEvent PointerEnter = new PointerUnityEvent();
  7. public PointerUnityEvent PointerDown = new PointerUnityEvent();
  8. public PointerUnityEvent PointerClick = new PointerUnityEvent();
  9. public PointerUnityEvent PointerUp = new PointerUnityEvent();
  10. public PointerUnityEvent PointerExit = new PointerUnityEvent();
  11. public PointerUnityEvent PointerDrag = new PointerUnityEvent();
  12. public virtual void OnDrag(PointerEventData eventData) {
  13. PointerDrag?.Invoke(eventData);
  14. }
  15. public virtual void OnPointerClick(PointerEventData eventData) {
  16. PointerClick?.Invoke(eventData);
  17. }
  18. public virtual void OnPointerDown(PointerEventData eventData) {
  19. PointerDown?.Invoke(eventData);
  20. }
  21. public virtual void OnPointerEnter(PointerEventData eventData) {
  22. PointerEnter?.Invoke(eventData);
  23. }
  24. public virtual void OnPointerExit(PointerEventData eventData) {
  25. PointerExit?.Invoke(eventData);
  26. }
  27. public virtual void OnPointerUp(PointerEventData eventData) {
  28. PointerUp?.Invoke(eventData);
  29. }
  30. }
  31. [System.Serializable]
  32. public class PointerUnityEvent : UnityEvent<PointerEventData> { }