using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class tishi_count : MonoBehaviour { public Toggle 服务记录仪器; public GameObject 已打开; public GameObject 已关闭; private bool start; public float time =0; // Start is called before the first frame update void Start() { 服务记录仪器.onValueChanged.AddListener(starttishi); } // Update is called once per frame void Update() { if (start == true) { time += Time.deltaTime; } if (time > 5) { start = false; time = 0; 已打开.SetActive(false); 已关闭.SetActive(false); } } public void starttishi(bool change) { start = true; time = 0; if (服务记录仪器.isOn == true) { 已打开.SetActive(true); 已关闭.SetActive(false); ///服务记录仪器.colors = ColorBlock.defaultColorBlock; } else { 已关闭.SetActive(true); 已打开.SetActive(false); } } }