123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using UnityEngine;
- // Use this Script in parent folder of all Humans
- public class ChangeModelTransMaterialTime: MonoBehaviour
- {
- [Header("Model Materials:")]
- public Material default_mat;
- public int groups;
- // 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])
- {
- child.Find("BasicMotionsDummyModel").Find("DummyMesh").GetComponent<SkinnedMeshRenderer>().material = default_mat;
- Color instance_col = child.Find("BasicMotionsDummyModel").Find("DummyMesh").GetComponent<SkinnedMeshRenderer>().material.color;
- if(child.CompareTag("2021"))
- {
- instance_col.a = (float) 3 / groups;
- }
- else if (child.CompareTag("2020"))
- {
- instance_col.a = (float) 2 / groups;
- }
- else if (child.CompareTag("2019"))
- {
- instance_col.a = (float) 1 / groups;
- }
- else
- {
- instance_col.a = 0F;
- }
- child.Find("BasicMotionsDummyModel").Find("DummyMesh").GetComponent<SkinnedMeshRenderer>().material.color = instance_col;
- }
- }
- }
- }
|