123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class HumitdlyPanel : MonoBehaviour
- {
- public Image stateImage;
- public Text stateText;
- public Text deviceId;
- public Text TempText;
- public Text humitdlyText;
- public string state;
- private HumitureMqttData data;
- public void SetData(HumitureMqttData data)
- {
- if (data == null)
- return;
- this.data = data;
- switch (state)
- {
- case "±¨¾¯":
- stateImage.color = new Color32(255, 3, 7, 100);
- stateText.text = "Òì³£";
- stateText.color = new Color32(255, 3, 7, 255);
- break;
- default:
- stateImage.color = new Color32(34, 187, 67, 100);
- stateText.text = "Õý³£";
- stateText.color = new Color32(34, 187, 67, 255);
-
- break;
- }
- deviceId.text = data.device.deviceName;
- TempText.text = data.temperature.value + data.temperature.unit;
- humitdlyText.text = data.humidity.value + data.humidity.unit;
- }
- }
|