12345678910111213141516171819202122232425262728293031323334 |
- 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)
- {
- Debug.Log("OnColorChange");
- if (back2XRIcon3D)
- {
- UnityUtil.ChangeMateColor(back2XRIcon3D, isOn ? changeColor : originalColor, "_Color");
- }
- }
- }
|