GQ_Communicate/GQ_TongXin/Assets/Scripts/WJ/SpUI.cs

77 lines
2.0 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 Image expand_image;
public Sprite wendu_expand;
public Sprite shidu_expand;
public TextMeshProUGUI textMeshPro;
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 = "26¡ãC";
break;
case "ʪ¶È":
my_image.sprite = shidu_selected;
expand_image.sprite = shidu_expand;
textMeshPro.text = "40 %";
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;
default:
break;
}
my_image.SetNativeSize();
}
public void ChangeWSD(string wsd)
{
switch (TemperatureAndHumidity.current_state)
{
case "ζÈ":
my_image.sprite = wendu_normal;
break;
case "ʪ¶È":
my_image.sprite = shidu_normal;
break;
default:
break;
}
}
}