uGUIPanel.cs 730 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. public class uGUIPanel : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IEventSystemHandler
  5. {
  6. private void OnHover(bool isOver)
  7. {
  8. GameMain.Instance.MainCamera.gameObject.SendMessage("OnHover", isOver, SendMessageOptions.DontRequireReceiver);
  9. }
  10. public void OnPointerEnter(PointerEventData eventData)
  11. {
  12. this.OnHover(false);
  13. this.isEnter = true;
  14. }
  15. public void OnPointerExit(PointerEventData eventData)
  16. {
  17. if (this.isEnter)
  18. {
  19. this.OnHover(true);
  20. this.isEnter = false;
  21. }
  22. }
  23. private void Update()
  24. {
  25. if (this.isEnter && GameMain.Instance.MainCamera.IsFallThrough)
  26. {
  27. this.OnHover(false);
  28. }
  29. }
  30. private bool isEnter;
  31. }