using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class TemperatureAndHumidity : CabinetUIBase { public static Transform Camera; /// /// 当前状态为温度还是湿度 /// public static string current_state = "温度"; public SpUI sp_ui; public Color hightC; // Start is called before the first frame update void Start() { Camera = UnityEngine.Camera.main.transform; } // Update is called once per frame void Update() { transform.eulerAngles = Camera.eulerAngles; } [ContextMenu("温度")] public void tw() { ChangeState("温度"); } [ContextMenu("湿度")] public void sw() { ChangeState("湿度"); } public void ChangeState(string state) { current_state = state; sp_ui.ChangeWSD(current_state); } public override void OnMenuChanged(Menu menu) { base.OnMenuChanged(menu); if (menu == Menu.M_全景监控_温度) { var _a = transform.parent.GetComponent().eNVList_W.collectResult; var _b = GameManager.Inst.arguments.heatThresholdValue; var a = string.IsNullOrEmpty(_a) ? "0" : _a; var b = string.IsNullOrEmpty(_b) ? "0" : _b; if (float.Parse(a) > float.Parse(b)) transform.Find("Canvas/Icon").GetComponent().color = hightC; else transform.Find("Canvas/Icon").GetComponent().color = new Color(1, 1, 1, 1); gameObject.SetActive(true); ChangeState("温度"); } else if (menu == Menu.M_全景监控_湿度) { var _a = transform.parent.GetComponent().eNVList_S.collectResult; var _b = GameManager.Inst.arguments.humidityThresholdValue; var a = string.IsNullOrEmpty(_a) ? "0" : _a; var b = string.IsNullOrEmpty(_b) ? "0" : _b; if (float.Parse(a) > float.Parse(b)) transform.Find("Canvas/Icon").GetComponent().color = hightC; else transform.Find("Canvas/Icon").GetComponent().color = new Color(1, 1, 1, 1); gameObject.SetActive(true); ChangeState("湿度"); } else { gameObject.SetActive(false); } } }