MouseDownUp.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class MouseDownUp : MonoBehaviour
  6. {
  7. private string m_UIEventKey;
  8. InputEventRegisterInfo<InputUIOnMouseEvent> inputUIOnMouseEventDown;
  9. InputEventRegisterInfo<InputUIOnMouseEvent> inputUIOnMouseEventUp;
  10. public virtual void InitEvent(string UIEventKey)
  11. {
  12. m_UIEventKey = UIEventKey;
  13. InputUIEventProxy.GetOnMouseListener(m_UIEventKey, name, name, true, OnMouseDownEvent);
  14. InputUIEventProxy.GetOnMouseListener(m_UIEventKey, name, name, false, OnMouseUpEvent);
  15. }
  16. public virtual void OnMouseDownEvent(InputUIOnMouseEvent inputEvent)
  17. {
  18. }
  19. public virtual void OnMouseUpEvent(InputUIOnMouseEvent inputEvent)
  20. {
  21. }
  22. public void DisposeEvent()
  23. {
  24. inputUIOnMouseEventDown.RemoveListener();
  25. inputUIOnMouseEventUp.RemoveListener();
  26. inputUIOnMouseEventDown = null;
  27. inputUIOnMouseEventUp = null;
  28. }
  29. private void OnMouseDown()
  30. {
  31. InputUIEventProxy.DispatchMouseEvent(name, name, true, null);
  32. }
  33. private void OnMouseUp()
  34. {
  35. InputUIEventProxy.DispatchMouseEvent(name, name, false, null);
  36. }
  37. }