123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 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<XRImage3D>()))
- {
- 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;
- }
-
- }
- }
|