Change3DIconColor.cs 880 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using XRTool.Util;
  7. using XRTool.WorldUI;
  8. public class Change3DIconColor : MonoBehaviour
  9. {
  10. public Color originalColor;
  11. public Color changeColor;
  12. private Renderer back2XRIcon3D;
  13. void Start()
  14. {
  15. var toggle = GetComponent<Toggle>();
  16. toggle.onValueChanged.AddListener(OnColorChange);
  17. var obj = UnityUtil.GetBreadthChild<XRImage3D>(transform, "Back2XRIcon3D");
  18. if (obj)
  19. {
  20. back2XRIcon3D = obj.BodyRender;
  21. }
  22. OnColorChange(toggle.isOn);
  23. }
  24. private void OnColorChange(bool isOn)
  25. {
  26. Debug.Log("OnColorChange");
  27. if (back2XRIcon3D)
  28. {
  29. UnityUtil.ChangeMateColor(back2XRIcon3D, isOn ? changeColor : originalColor, "_Color");
  30. }
  31. }
  32. }