PopImage.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. public class PopImage : PopBase, IPointerUpHandler, IPointerDownHandler
  6. {
  7. [SerializeField]
  8. private Game3DButton CloseBtn;
  9. [SerializeField]
  10. private UnityEngine.UI.RawImage Image;
  11. protected override void Start()
  12. {
  13. base.Start();
  14. CloseBtn.onClick.AddListener(OnClick);
  15. }
  16. //框体类型
  17. public override PopType MType { get { return PopType.Image; } }
  18. public override void Show(System.Object data)
  19. {
  20. UnityEngine.UI.RawImage target = data as UnityEngine.UI.RawImage;
  21. this.Image.texture = target.texture;
  22. base.Show();
  23. CDebug.Log("显示");
  24. }
  25. private void OnClick()
  26. {
  27. this.Hide();
  28. }
  29. private bool isEnter = false;
  30. public virtual void OnPointerUp(PointerEventData eventData)
  31. {
  32. if (isEnter)
  33. {
  34. isEnter = false;
  35. CDebug.Log("隐藏OnPointerDown");
  36. OnClick();
  37. }
  38. }
  39. public virtual void OnPointerDown(PointerEventData eventData)
  40. {
  41. isEnter = true;
  42. }
  43. }