12345678910111213141516171819202122232425262728293031323334 |
- using UnityEngine;
- // Use this Script in parent folder of all Humans
- public class SetDiamondMaterial : MonoBehaviour
- {
- [Header("Diamond Materials:")]
- public Material year2019;
- public Material year2020;
- public Material year2021;
- // Start is called before the first frame update
- void Start()
- {
- Component[] allChild = GetComponentsInChildren<Transform>(); // all possible children of parent object
- foreach (Transform child in allChild)
- {
- if (child.parent == allChild[0])
- {
- if(child.CompareTag("2021"))
- {
- child.Find("BasicMotionsDummyModel").Find("diamond1").GetComponent<MeshRenderer>().material = year2021;
- }
- else if (child.CompareTag("2020"))
- {
- child.Find("BasicMotionsDummyModel").Find("diamond1").GetComponent<MeshRenderer>().material = year2020;
- }
- else if (child.CompareTag("2019"))
- {
- child.Find("BasicMotionsDummyModel").Find("diamond1").GetComponent<MeshRenderer>().material = year2019;
- }
- }
- }
- }
- }
|