180 lines
6.4 KiB
C#
180 lines
6.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class SpUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
public Image my_image;
|
|
|
|
public Sprite wendu_normal;
|
|
public Sprite wendu_selected;
|
|
public Sprite shidu_normal;
|
|
public Sprite shidu_selected;
|
|
public Sprite yangan_normal;
|
|
public Sprite yangan_selected;
|
|
public Sprite shuijin_normal;
|
|
public Sprite shuijin_selected;
|
|
|
|
public Image expand_image;
|
|
|
|
public Sprite wendu_expand;
|
|
public Sprite shidu_expand;
|
|
public Sprite yangan_expand;
|
|
public Sprite shuijin_expand;
|
|
|
|
public TextMeshProUGUI textMeshPro;
|
|
public Text text;
|
|
|
|
public Color hightC;
|
|
public Color hightM;
|
|
public Transform temperatureAndHumidity;
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
expand_image.gameObject.SetActive(true);
|
|
switch (TemperatureAndHumidity.current_state)
|
|
{
|
|
case "ζÈ":
|
|
{
|
|
my_image.sprite = wendu_selected;
|
|
expand_image.sprite = wendu_expand;
|
|
textMeshPro.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_W.collectResult;
|
|
text.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_W.collectResult;
|
|
}
|
|
break;
|
|
case "ʪ¶È":
|
|
{
|
|
my_image.sprite = shidu_selected;
|
|
expand_image.sprite = shidu_expand;
|
|
textMeshPro.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_S.collectResult;
|
|
text.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_S.collectResult;
|
|
}
|
|
break;
|
|
case "Ñ̸Ð":
|
|
{
|
|
my_image.sprite = yangan_selected;
|
|
expand_image.sprite = yangan_expand;
|
|
textMeshPro.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_Y.collectResult;
|
|
text.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_Y.collectResult;
|
|
}
|
|
break;
|
|
case "Ë®½þ":
|
|
{
|
|
my_image.sprite = shuijin_selected;
|
|
expand_image.sprite = shuijin_expand;
|
|
textMeshPro.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_J.collectResult;
|
|
text.text = transform.parent.parent.parent.GetComponent<ENVQuery>().eNVList_J.collectResult;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
my_image.SetNativeSize();
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
expand_image.gameObject.SetActive(false);
|
|
switch (TemperatureAndHumidity.current_state)
|
|
{
|
|
case "ζÈ":
|
|
my_image.sprite = wendu_normal;
|
|
break;
|
|
case "ʪ¶È":
|
|
my_image.sprite = shidu_normal;
|
|
break;
|
|
case "Ñ̸Ð":
|
|
my_image.sprite = yangan_normal;
|
|
break;
|
|
case "Ë®½þ":
|
|
my_image.sprite = shuijin_normal;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
my_image.SetNativeSize();
|
|
}
|
|
|
|
public void ChangeWSD(string wsd)
|
|
{
|
|
string _a = null;
|
|
string _max = null;
|
|
string _min = null;
|
|
switch (TemperatureAndHumidity.current_state)
|
|
{
|
|
case "ζÈ":
|
|
{
|
|
_a = temperatureAndHumidity.parent.GetComponent<ENVQuery>().eNVList_W.collectResult;
|
|
_max = GameManager.Inst.arguments.heatThresholdValueMax;
|
|
_min = GameManager.Inst.arguments.heatThresholdValueMin;
|
|
my_image.sprite = wendu_normal;
|
|
if (string.IsNullOrEmpty(_a)) transform.parent.parent.gameObject.SetActive(false);
|
|
}
|
|
break;
|
|
case "ʪ¶È":
|
|
{
|
|
_a = temperatureAndHumidity.parent.GetComponent<ENVQuery>().eNVList_S.collectResult;
|
|
_max = GameManager.Inst.arguments.humidityThresholdValueMax;
|
|
_min = GameManager.Inst.arguments.humidityThresholdValueMin;
|
|
my_image.sprite = shidu_normal;
|
|
if (string.IsNullOrEmpty(_a)) transform.parent.parent.gameObject.SetActive(false);
|
|
}
|
|
break;
|
|
case "Ñ̸Ð":
|
|
{
|
|
_a = temperatureAndHumidity.parent.GetComponent<ENVQuery>().eNVList_Y.collectResult;
|
|
my_image.sprite = yangan_normal;
|
|
if (string.IsNullOrEmpty(_a)) transform.parent.parent.gameObject.SetActive(false);
|
|
}
|
|
break;
|
|
case "Ë®½þ":
|
|
{
|
|
_a = temperatureAndHumidity.parent.GetComponent<ENVQuery>().eNVList_J.collectResult;
|
|
my_image.sprite = shuijin_normal;
|
|
if (string.IsNullOrEmpty(_a)) transform.parent.parent.gameObject.SetActive(false);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (string.IsNullOrEmpty(_a))
|
|
{
|
|
if (transform.parent.parent.name == "ÎÂʪ¶È")
|
|
{
|
|
transform.parent.parent.gameObject.SetActive(false);
|
|
}
|
|
return;
|
|
}
|
|
if (TemperatureAndHumidity.current_state != "Ñ̸Ð" && TemperatureAndHumidity.current_state != "Ë®½þ")
|
|
{
|
|
var a = string.IsNullOrEmpty(_a) ? "0" : _a;
|
|
var max = string.IsNullOrEmpty(_max) ? "0" : _max;
|
|
var min = string.IsNullOrEmpty(_min) ? "0" : _min;
|
|
if (float.Parse(a) > float.Parse(max))
|
|
my_image.color = hightC;
|
|
if (float.Parse(a) < float.Parse(min))
|
|
my_image.color = hightM;
|
|
else
|
|
my_image.color = new Color(1, 1, 1, 1);
|
|
}
|
|
else
|
|
{
|
|
if (_a == "Õý³£")
|
|
{
|
|
my_image.color = new Color(1, 1, 1, 1);
|
|
}
|
|
else
|
|
{
|
|
my_image.color = hightC;
|
|
}
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|