using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class AccidentManager : MonoBehaviour { public GameObject uis; private string triggerName; private void OnTriggerEnter(Collider other) { triggerName = other.name; uis.SetActive(true); for (int i = 0; i < uis.transform.childCount; i++) { uis.transform.GetChild(i).gameObject.SetActive(false); } if (other.transform.tag == "People") { uis.transform.Find("撞倒行人").gameObject.SetActive(true); } else if (other.name == "chechufa") { uis.transform.Find("汽车追尾").gameObject.SetActive(true); } else if (other.name == "爆胎") { uis.transform.Find("爆胎").gameObject.SetActive(true); } // switch (other.name) // { // case "刹车失灵": // uis.transform.Find("刹车失灵").gameObject.SetActive(true); // break; // case "礼让行人": // uis.transform.Find("礼让行人").gameObject.SetActive(true); // break; // case "汽车追尾": // uis.transform.Find("汽车追尾").gameObject.SetActive(true); // break; // case "电动车穿行": // uis.transform.Find("电动车穿行").gameObject.SetActive(true); // break; // case "撞倒行人": // uis.transform.Find("撞倒行人").gameObject.SetActive(true); // break; // case "爆胎": // uis.transform.Find("爆胎").gameObject.SetActive(true); // break; // } } private void OnTriggerExit(Collider other) { for (int i = 0; i < uis.transform.childCount; i++) { uis.transform.GetChild(i).gameObject.SetActive(false); } uis.SetActive(false); } }