1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using DG.Tweening;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- namespace XRTool.WorldUI
- {
- public class XRToggle : Toggle
- {
- private GameObject checkXRIcon3D;
- /// <summary>
- /// 是否隐藏取消框
- /// </summary>
- public bool isHideCheck = true;
- public Vector3 openPos = Vector3.right;
- public float moveTime = 0.3f;
- private Vector3 initPos = Vector3.zero;
- public bool isSwitch;
- public GameObject CheckXRIcon3D
- {
- get
- {
- if (!checkXRIcon3D)
- {
- checkXRIcon3D = UnityUtil.GetBreadthChild(transform, "CheckXRIcon3D");
- initPos = checkXRIcon3D.transform.localPosition;
- }
- return checkXRIcon3D;
- }
- }
- protected override void Awake()
- {
- base.Awake();
- initListen();
- }
- public void initListen()
- {
- if (CheckXRIcon3D) { }
- onValueChanged.RemoveListener(OnToggleChanged);
- onValueChanged.AddListener(OnToggleChanged);
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- onValueChanged.RemoveAllListeners();
- }
- public virtual void OnToggleChanged(bool isOn)
- {
- if (CheckXRIcon3D)
- {
- CheckXRIcon3D.SetActive(isOn);
- }
- }
- }
- }
|