135 lines
4.6 KiB
C#
135 lines
4.6 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 Image expand_image;
|
|
|
|
public Sprite wendu_expand;
|
|
public Sprite shidu_expand;
|
|
public Sprite yangan_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;
|
|
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;
|
|
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;
|
|
}
|
|
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;
|
|
}
|
|
break;
|
|
//case "Ñ̸Ð":
|
|
// {
|
|
// _a = temperatureAndHumidity.parent.GetComponent<ENVQuery>().eNVList_Y.collectResult;
|
|
// _max = GameManager.Inst.arguments.humidityThresholdValueMax;
|
|
// my_image.sprite = yangan_normal;
|
|
// }
|
|
//break;
|
|
default:
|
|
break;
|
|
}
|
|
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);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|