1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class GongChengLieBiaoItem : MonoBehaviour
- {
- public GongChengLieBiaoData _currentData;
- private Text _indexText;
- private Text _nameText;
- private Text _stateText;
- private Button _button;
- private Image _highLightImg;
- public void Init()
- {
- _indexText = this.transform.Find("index").GetComponent<Text>();
- _nameText = this.transform.Find("type").GetComponent<Text>();
- _stateText = this.transform.Find("state").GetComponent<Text>();
- _highLightImg = this.transform.Find("highLight").GetComponent<Image>();
- _button = this.GetComponent<Button>();
- _button.onClick.AddListener(ItemClick);
- }
- public void ItemClick()
- {
- switch (_currentData.type)
- {
- case GongChengType.all:
- case GongChengType.shiPin:
- break;
- default:
- GCJKLayer._Instance.OpenDeviceTrendPanel(_currentData.name, _currentData.type, _currentData.gid,
- _currentData.sid);
- break;
- }
- }
- private void OnDestroy()
- {
- // if (GCJKLayer._Instance.currentSelectItem != null && GCJKLayer._Instance.currentSelectItem == this)
- // {
- // GCJKLayer._Instance.currentSelectItem = null;
- // }
- }
- public void SetHighLight(bool show)
- {
- _highLightImg.enabled = show;
- }
- public void SetData(GongChengLieBiaoData data)
- {
- _currentData = data;
- _indexText.text = $"{_currentData.index:00}";
- _nameText.text = $"{_currentData.name}";
- switch (_currentData.state)
- {
- case GongChengState.normal:
- _stateText.text = $"<color=#15DCFC>正常</color>";
- break;
- case GongChengState.runing:
- _stateText.text = $"<color=#15DCFC>运行</color>";
- break;
- case GongChengState.fix:
- _stateText.text = $"<color=#FFBC1D>养护</color>";
- break;
- case GongChengState.warning:
- _stateText.text = $"<color=#EF491C>告警</color>";
- break;
- }
- }
- }
|