46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
// 切换新风机组
|
||
|
|
public class CutAir : MonoBehaviour,IPointerClickHandler
|
||
|
|
{
|
||
|
|
public GameObject air;
|
||
|
|
public Sprite runSprite; // 运行状态的图片
|
||
|
|
public Sprite stopSprite; // 停止状态的图片
|
||
|
|
|
||
|
|
private List<string> deviceIds;
|
||
|
|
private int index=1;
|
||
|
|
private bool isRun=true;
|
||
|
|
|
||
|
|
public void OnEnable()
|
||
|
|
{
|
||
|
|
deviceIds = new List<string>{"AHU_5_03","AHU_5_04"};
|
||
|
|
StartCoroutine(AutoCut());
|
||
|
|
}
|
||
|
|
|
||
|
|
public IEnumerator AutoCut()
|
||
|
|
{
|
||
|
|
yield return new WaitForSeconds(10);
|
||
|
|
while (isRun)
|
||
|
|
{
|
||
|
|
FreshAirVentilatorController.deviceId = deviceIds[index];
|
||
|
|
index++;
|
||
|
|
if (index >= deviceIds.Count) index = 0;
|
||
|
|
air.SetActive(false);
|
||
|
|
air.SetActive(true);
|
||
|
|
// print("切换了通风柜");
|
||
|
|
yield return new WaitForSeconds(10);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnPointerClick(PointerEventData eventData)
|
||
|
|
{
|
||
|
|
isRun = !isRun;
|
||
|
|
gameObject.GetComponent<Image>().sprite = isRun?stopSprite:runSprite;
|
||
|
|
if (isRun)StartCoroutine(AutoCut());
|
||
|
|
}
|
||
|
|
}
|