GongChengLieBiaoItem.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class GongChengLieBiaoItem : MonoBehaviour
  7. {
  8. public GongChengLieBiaoData _currentData;
  9. private Text _indexText;
  10. private Text _nameText;
  11. private Text _stateText;
  12. private Button _button;
  13. private Image _highLightImg;
  14. public void Init()
  15. {
  16. _indexText = this.transform.Find("index").GetComponent<Text>();
  17. _nameText = this.transform.Find("type").GetComponent<Text>();
  18. _stateText = this.transform.Find("state").GetComponent<Text>();
  19. _highLightImg = this.transform.Find("highLight").GetComponent<Image>();
  20. _button = this.GetComponent<Button>();
  21. _button.onClick.AddListener(ItemClick);
  22. }
  23. public void ItemClick()
  24. {
  25. switch (_currentData.type)
  26. {
  27. case GongChengType.all:
  28. case GongChengType.shiPin:
  29. break;
  30. default:
  31. GCJKLayer._Instance.OpenDeviceTrendPanel(_currentData.name, _currentData.type, _currentData.gid,
  32. _currentData.sid);
  33. break;
  34. }
  35. }
  36. private void OnDestroy()
  37. {
  38. // if (GCJKLayer._Instance.currentSelectItem != null && GCJKLayer._Instance.currentSelectItem == this)
  39. // {
  40. // GCJKLayer._Instance.currentSelectItem = null;
  41. // }
  42. }
  43. public void SetHighLight(bool show)
  44. {
  45. _highLightImg.enabled = show;
  46. }
  47. public void SetData(GongChengLieBiaoData data)
  48. {
  49. _currentData = data;
  50. _indexText.text = $"{_currentData.index:00}";
  51. _nameText.text = $"{_currentData.name}";
  52. switch (_currentData.state)
  53. {
  54. case GongChengState.normal:
  55. _stateText.text = $"<color=#15DCFC>正常</color>";
  56. break;
  57. case GongChengState.runing:
  58. _stateText.text = $"<color=#15DCFC>运行</color>";
  59. break;
  60. case GongChengState.fix:
  61. _stateText.text = $"<color=#FFBC1D>养护</color>";
  62. break;
  63. case GongChengState.warning:
  64. _stateText.text = $"<color=#EF491C>告警</color>";
  65. break;
  66. }
  67. }
  68. }