Change3DIconColor.cs 844 B

123456789101112131415161718192021222324252627282930313233
  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. if (back2XRIcon3D)
  27. {
  28. UnityUtil.ChangeMateColor(back2XRIcon3D, isOn ? changeColor : originalColor, "_Color");
  29. }
  30. }
  31. }