using System.Runtime.ConstrainedExecution; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using static SensorAlert; public class YiChangJingGaoItem : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler { public YiChangJingGaoData currentData; public SWAlert currentSWAlertData; public SensorAlertData currentSensorData; private Text _timeText; private Text _posText; private Text _typeText; private Text _infoText; private Text _stateText; public void Init() { _timeText = this.transform.Find("time").GetComponent(); _posText = this.transform.Find("pos").GetComponent(); _typeText = this.transform.Find("type").GetComponent(); _infoText = this.transform.Find("info").GetComponent(); _stateText = this.transform.Find("state").GetComponent(); } public void OnPointerEnter(PointerEventData eventData) { Debug.Log(11); } public void OnPointerExit(PointerEventData eventData) { Debug.Log(22); } public void SetData(YiChangJingGaoData data) { currentData = data; _timeText.text = currentData.time; _posText.text = currentData.pos; _typeText.text = currentData.type; _infoText.text = currentData.info; _stateText.text = currentData.state; } public void SetData(SWAlert data) { currentSWAlertData = data; _timeText.text = data.triggerTime.ToString(); _posText.text = data.projectName.ToString().Substring(0,2); _typeText.text = data.alertType.ToString(); if (data.alertMessage.Contains('£¬')) { string[] per = data.alertMessage.Split('£¬'); _infoText.text = per[per.Length - 1]; } else{ _infoText.text = data.alertMessage; } } public void SetData(SensorAlertData data) { currentSensorData = data; _timeText.text = data.triggerTime.ToString(); _posText.text = data.projectName.ToString().Substring(0, 2); if(data.alertType != null) _typeText.text = data.alertType.ToString(); _infoText.text = data.alertMessage; } }