using UnityEngine; // Use this Script in parent folder of all Humans public class SetDiamondMaterialTimeOld : MonoBehaviour { [Header("Visibility:")] public bool showHumans = true; [Header("Diamond Materials:")] public Material year2019; public Material year2020; public Material year2021; public Material default_mat; // Start is called before the first frame update void Start() { Component[] years = gameObject.GetComponentsInChildren(); foreach (var year in years) { GameObject[][] humansGO = year.GetComponent().humanGameObject; for (int i = 0; i < humansGO.Length; ++i) for (int j = 0; j < humansGO[i].Length; ++j) { // Diamond object is visible humansGO[i][j].transform.Find("Diamond").gameObject.SetActive(true); // If bool showHumans is not ticked, then the DummyModel is not visible if (!showHumans) humansGO[i][j].transform.Find("DummyModel").gameObject.SetActive(false); if (humansGO[i][j].CompareTag("2021")) humansGO[i][j].transform.Find("Diamond").GetComponent().material = year2021; else if (humansGO[i][j].CompareTag("2020")) humansGO[i][j].transform.Find("Diamond").GetComponent().material = year2020; else if (humansGO[i][j].CompareTag("2019")) humansGO[i][j].transform.Find("Diamond").GetComponent().material = year2019; else humansGO[i][j].transform.Find("Diamond").GetComponent().material = default_mat; } } } }