ScanPictureBtn.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using ShadowStudio.UI;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.EventSystems;
  7. using UnityEngine.UI;
  8. using XRTool.Util;
  9. public class ScanPictureBtn : UnitySingleton<ScanPictureBtn>,IPointerEnterHandler,IPointerExitHandler
  10. {
  11. private Button scanPictureBtn;
  12. private Transform BtnTip;
  13. public Transform Bg;
  14. private Animator animator;
  15. protected override void Awake()
  16. {
  17. base.Awake();
  18. scanPictureBtn = transform.GetComponent<Button>();
  19. BtnTip = UnityUtil.GetBreadthChild<Transform>(transform, "BtnTip");
  20. Bg = UnityUtil.GetBreadthChild<Transform>(transform, "Bg");
  21. animator = UnityUtil.GetBreadthChild<Animator>(transform, "Action");
  22. scanPictureBtn.onClick.AddListener(OnClick);
  23. }
  24. private void OnClick()
  25. {
  26. if (ConsoleDlg.Instance)
  27. {
  28. ConsoleDlg.Instance.ClickOnScan();
  29. }
  30. }
  31. public void OnPointerEnter(PointerEventData eventData)
  32. {
  33. if (BtnTip && animator)
  34. {
  35. BtnTip.gameObject.SetActive(true);
  36. animator.SetBool("Show", true);
  37. }
  38. }
  39. public void OnPointerExit(PointerEventData eventData)
  40. {
  41. if (BtnTip && animator)
  42. {
  43. BtnTip.gameObject.SetActive(false);
  44. animator.SetBool("Show", false);
  45. }
  46. }
  47. }