CQ_Intelligent-Technology-T.../Assets/Scripts/智慧交通/Exceptionhandling.cs

58 lines
2.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Exceptionhandling : MonoBehaviour
{
/// <summary>
/// 重启按钮
/// </summary>
public Button Restarbt;
/// <summary>
/// 异常按钮
/// </summary>
public GameObject ErrorBt;
void Start()
{
Restarbt.onClick.AddListener(() => { ErrorBt.SetActive(false); StartCoroutine(RestarLight()); });
}
/// <summary>
/// 异常处理
/// </summary>
public void Exception()
{
ControlLight.Instance.redlight1.GetComponent<Renderer>().material.DisableKeyword("_EMISSION");
ControlLight.Instance.yellowlight1.GetComponent<Renderer>().material.EnableKeyword("_EMISSION");
ControlLight.Instance.LightNumber1.text = "0F";
ControlLight.Instance.redlight2.GetComponent<Renderer>().material.DisableKeyword("_EMISSION");
ControlLight.Instance.yellowlight2.GetComponent<Renderer>().material.EnableKeyword("_EMISSION");
ControlLight.Instance.LightNumber2.text = "0F";
}
IEnumerator RestarLight()
{
ImageTips.instance.TipPanel.SetActive(true);
ImageTips.instance.Tips.color = Color.red;
ImageTips.instance.Tips.text = "设备正在重启.";
yield return new WaitForSeconds(0.2f);
ImageTips.instance.Tips.text = "设备正在重启..";
yield return new WaitForSeconds(0.2f);
ImageTips.instance.Tips.text = "设备正在重启...";
yield return new WaitForSeconds(3f);
ImageTips.instance.Tips.color = Color.green;
ImageTips.instance.Tips.text = "设备重启完成";
yield return new WaitForSeconds(2);
ImageTips.instance.TipPanel.SetActive(false);
ControlLight.Instance.greenlight1.GetComponent<Renderer>().material.EnableKeyword("_EMISSION");
ControlLight.Instance.yellowlight1.GetComponent<Renderer>().material.DisableKeyword("_EMISSION");
ControlLight.Instance.LightNumber1.text = "99";
ControlLight.Instance.LightNumber1.color=Color.green;
ControlLight.Instance.LightBox1.SetActive(false);
ControlLight.Instance.greenlight2.GetComponent<Renderer>().material.EnableKeyword("_EMISSION");
ControlLight.Instance.yellowlight2.GetComponent<Renderer>().material.DisableKeyword("_EMISSION");
ControlLight.Instance.LightNumber2.text = "99";
ControlLight.Instance.LightNumber2.color = Color.green;
ControlLight.Instance.LightBox2.SetActive(false);
}
}