UIForwardEvents.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using UnityEngine;
  3. [AddComponentMenu("NGUI/Interaction/Forward Events (Legacy)")]
  4. public class UIForwardEvents : MonoBehaviour
  5. {
  6. private void OnHover(bool isOver)
  7. {
  8. if (this.onHover && this.target != null)
  9. {
  10. this.target.SendMessage("OnHover", isOver, SendMessageOptions.DontRequireReceiver);
  11. }
  12. }
  13. private void OnPress(bool pressed)
  14. {
  15. if (this.onPress && this.target != null)
  16. {
  17. this.target.SendMessage("OnPress", pressed, SendMessageOptions.DontRequireReceiver);
  18. }
  19. }
  20. private void OnClick()
  21. {
  22. if (this.onClick && this.target != null)
  23. {
  24. this.target.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);
  25. }
  26. }
  27. private void OnDoubleClick()
  28. {
  29. if (this.onDoubleClick && this.target != null)
  30. {
  31. this.target.SendMessage("OnDoubleClick", SendMessageOptions.DontRequireReceiver);
  32. }
  33. }
  34. private void OnSelect(bool selected)
  35. {
  36. if (this.onSelect && this.target != null)
  37. {
  38. this.target.SendMessage("OnSelect", selected, SendMessageOptions.DontRequireReceiver);
  39. }
  40. }
  41. private void OnDrag(Vector2 delta)
  42. {
  43. if (this.onDrag && this.target != null)
  44. {
  45. this.target.SendMessage("OnDrag", delta, SendMessageOptions.DontRequireReceiver);
  46. }
  47. }
  48. private void OnDrop(GameObject go)
  49. {
  50. if (this.onDrop && this.target != null)
  51. {
  52. this.target.SendMessage("OnDrop", go, SendMessageOptions.DontRequireReceiver);
  53. }
  54. }
  55. private void OnSubmit()
  56. {
  57. if (this.onSubmit && this.target != null)
  58. {
  59. this.target.SendMessage("OnSubmit", SendMessageOptions.DontRequireReceiver);
  60. }
  61. }
  62. private void OnScroll(float delta)
  63. {
  64. if (this.onScroll && this.target != null)
  65. {
  66. this.target.SendMessage("OnScroll", delta, SendMessageOptions.DontRequireReceiver);
  67. }
  68. }
  69. public GameObject target;
  70. public bool onHover;
  71. public bool onPress;
  72. public bool onClick;
  73. public bool onDoubleClick;
  74. public bool onSelect;
  75. public bool onDrag;
  76. public bool onDrop;
  77. public bool onSubmit;
  78. public bool onScroll;
  79. }