NoisePanel.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class NoisePanel : MonoBehaviour
  6. {
  7. public Image stateImage;
  8. public Text stateText;
  9. public Text deviceId;
  10. public Text noiseText;
  11. public string state;
  12. private NoiseMqttData data;
  13. public void SetData(NoiseMqttData data)
  14. {
  15. if (data == null)
  16. return;
  17. this.data = data;
  18. switch (state)
  19. {
  20. case "ą¨žŻ":
  21. stateImage.color = new Color32(255, 3, 7, 100);
  22. stateText.text = "Ň쳣";
  23. stateText.color = new Color32(255, 3, 7, 255);
  24. break;
  25. default:
  26. stateImage.color = new Color32(34, 187, 67, 100);
  27. stateText.text = "ŐýłŁ";
  28. stateText.color = new Color32(34, 187, 67, 255);
  29. break;
  30. }
  31. deviceId.text = data.device.deviceName;
  32. noiseText.text = data.value + data.unit;
  33. }
  34. }