SetDiamondMaterial.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using UnityEngine;
  2. // Use this Script in parent folder of all Humans
  3. public class SetDiamondMaterial : MonoBehaviour
  4. {
  5. [Header("Diamond Materials:")]
  6. public Material year2019;
  7. public Material year2020;
  8. public Material year2021;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. Component[] allChild = GetComponentsInChildren<Transform>(); // all possible children of parent object
  13. foreach (Transform child in allChild)
  14. {
  15. if (child.parent == allChild[0])
  16. {
  17. if(child.CompareTag("2021"))
  18. {
  19. child.Find("BasicMotionsDummyModel").Find("diamond1").GetComponent<MeshRenderer>().material = year2021;
  20. }
  21. else if (child.CompareTag("2020"))
  22. {
  23. child.Find("BasicMotionsDummyModel").Find("diamond1").GetComponent<MeshRenderer>().material = year2020;
  24. }
  25. else if (child.CompareTag("2019"))
  26. {
  27. child.Find("BasicMotionsDummyModel").Find("diamond1").GetComponent<MeshRenderer>().material = year2019;
  28. }
  29. }
  30. }
  31. }
  32. }