HumitdlyPanel.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class HumitdlyPanel : MonoBehaviour
  6. {
  7. public Image stateImage;
  8. public Text stateText;
  9. public Text deviceId;
  10. public Text TempText;
  11. public Text humitdlyText;
  12. public string state;
  13. private HumitureMqttData data;
  14. public void SetData(HumitureMqttData data)
  15. {
  16. if (data == null)
  17. return;
  18. this.data = data;
  19. switch (state)
  20. {
  21. case "±¨¾¯":
  22. stateImage.color = new Color32(255, 3, 7, 100);
  23. stateText.text = "Òì³£";
  24. stateText.color = new Color32(255, 3, 7, 255);
  25. break;
  26. default:
  27. stateImage.color = new Color32(34, 187, 67, 100);
  28. stateText.text = "Õý³£";
  29. stateText.color = new Color32(34, 187, 67, 255);
  30. break;
  31. }
  32. deviceId.text = data.device.deviceName;
  33. TempText.text = data.temperature.value + data.temperature.unit;
  34. humitdlyText.text = data.humidity.value + data.humidity.unit;
  35. }
  36. }