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