using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XRTool.UI; using XRTool.Util; namespace XRTool.WorldUI { public class XRButtonToggle : XRToggle,ItemCell { public Color closeColor = Color.white; public Color openColor = Color.green; private Renderer imgRenderer; public Renderer ImgRenderer { get { if (!imgRenderer) { XRImage3D xrImg = null; if (CheckXRIcon3D && (xrImg = CheckXRIcon3D.GetComponent())) { imgRenderer = xrImg.BodyRender; } } return imgRenderer; } } public GameObject GetInstance() { return gameObject; } public virtual void Hide() { if (targetGraphic) { targetGraphic.gameObject.SetActive(false); } } public override void OnToggleChanged(bool isOn) { if (ImgRenderer) { UnityUtil.ChangeMateColor(ImgRenderer, isOn ? openColor : closeColor, "_Color"); } } public virtual void SelectItem() { isOn = true; } public virtual void SetImage(Texture2D img) { if (ImgRenderer) { UnityUtil.ChangeMateTexture2D(ImgRenderer, img); } } public virtual void Show() { if (targetGraphic) { targetGraphic.gameObject.SetActive(true); } } public virtual void UnSelectItem() { isOn = false; } } }