BackChooseToggle.cs 989 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. using XRTool.Util;
  7. public class BackChooseToggle : MonoBehaviour,IPointerEnterHandler, IPointerExitHandler
  8. {
  9. private Transform BtnTip;
  10. private void Awake()
  11. {
  12. GetComponent<Toggle>().onValueChanged.AddListener(OnValueChanged);
  13. BtnTip = UnityUtil.GetBreadthChild<Transform>(transform, "BtnTip");
  14. }
  15. private void Start()
  16. {
  17. OnValueChanged(GetComponent<Toggle>().isOn);
  18. }
  19. private void OnValueChanged(bool value)
  20. {
  21. transform.GetChild(0).gameObject.SetActive(value);
  22. }
  23. public void OnPointerEnter(PointerEventData eventData)
  24. {
  25. if (BtnTip)
  26. {
  27. BtnTip.gameObject.SetActive(true);
  28. }
  29. }
  30. public void OnPointerExit(PointerEventData eventData)
  31. {
  32. if (BtnTip)
  33. {
  34. BtnTip.gameObject.SetActive(false);
  35. }
  36. }
  37. }