123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using UnityEngine;
- // Use this Script in parent folder of all Humans
- [DefaultExecutionOrder(70)]
- public class SetProjectorMaterialTime : MonoBehaviour
- {
- [Header("Projector Materials:")]
- public Material year2019;
- public Material year2020;
- public Material year2021;
- public Material default_mat;
- [Header("Thief Settings")]
- public Material thief_mat;
- public bool showThief2019 = false;
- public bool showThief2020 = false;
- public bool showThief2021 = false;
- // Start is called before the first frame update
- void Start()
- {
- Component[] years = gameObject.GetComponentsInChildren<InstantiatePrefab>();
- Component[] thiefs = gameObject.GetComponentsInChildren<ReadFromCSV>();
- foreach (var year in years)
- {
- GameObject[][] humansGO = year.GetComponent<InstantiatePrefab>().humanGameObject;
-
- for (int i = 0; i < humansGO.Length; ++i)
- for (int j = 0; j < humansGO[i].Length; ++j)
- {
- // Decal Game Object is visible
- humansGO[i][j].transform.Find("Decal").gameObject.SetActive(true);
-
- if (humansGO[i][j].CompareTag("2021"))
- humansGO[i][j].transform.Find("Decal").GetComponent<Projector>().material = year2021;
- else if (humansGO[i][j].CompareTag("2020"))
- humansGO[i][j].transform.Find("Decal").GetComponent<Projector>().material = year2020;
- else if (humansGO[i][j].CompareTag("2019"))
- humansGO[i][j].transform.Find("Decal").GetComponent<Projector>().material = year2019;
- else
- humansGO[i][j].transform.Find("Decal").GetComponent<Projector>().material = default_mat;
- }
- foreach (var thief in thiefs)
- {
- int thief_i = thief.GetComponent<ReadFromCSV>().thief_i;
- int thief_j = thief.GetComponent<ReadFromCSV>().thief_j;
- if (humansGO[0][0].CompareTag("2021") && thief.CompareTag("2021") && showThief2021)
- {
- humansGO[thief_i][thief_j].transform.Find("Decal").GetComponent<Projector>().material = thief_mat;
- break;
- }
- if (humansGO[0][0].CompareTag("2020") && thief.CompareTag("2020") && showThief2020)
- {
- humansGO[thief_i][thief_j].transform.Find("Decal").GetComponent<Projector>().material = thief_mat;
- break;
- }
- if (humansGO[0][0].CompareTag("2019") && thief.CompareTag("2019") && showThief2019)
- {
- humansGO[thief_i][thief_j].transform.Find("Decal").GetComponent<Projector>().material = thief_mat;
- break;
- }
- }
- }
- }
- }
|