123456789101112131415161718192021222324252627282930313233 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- public class Change3DIconColor : MonoBehaviour
- {
- public Color originalColor;
- public Color changeColor;
- private Renderer back2XRIcon3D;
- void Start()
- {
- var toggle = GetComponent<Toggle>();
- toggle.onValueChanged.AddListener(OnColorChange);
- var obj = UnityUtil.GetBreadthChild<XRImage3D>(transform, "Back2XRIcon3D");
- if (obj)
- {
- back2XRIcon3D = obj.BodyRender;
- }
- OnColorChange(toggle.isOn);
- }
- private void OnColorChange(bool isOn)
- {
- if (back2XRIcon3D)
- {
- UnityUtil.ChangeMateColor(back2XRIcon3D, isOn ? changeColor : originalColor, "_Color");
- }
- }
- }
|