using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class DeviceInfo : MonoBehaviour { public static DeviceInfo Instance; public GameObject infoItem; public Transform infoParent; public Text infoName; public Button CloseBtn; public DeviceList bindInfo; private void Awake() { Instance = this; gameObject.SetActive(false); } private void Start() { CloseBtn.onClick.AddListener(() => { gameObject.SetActive(false); }); } public void OnShow(DeviceList info) { infoName.text = "设备信息"; bindInfo = info; foreach (Transform item in infoParent) { if (item.name != "None") { Destroy(item.gameObject); } } if (info.deviceType == 256 || info.deviceType == 258) { { PLInfo pinfo = JsonConvert.DeserializeObject(info.timelyData.ToString()); GameObject go = Instantiate(infoItem, infoParent); go.GetComponent().Bind("名称:" + pinfo.deviceName); } { PLInfo pinfo = JsonConvert.DeserializeObject(info.timelyData.ToString()); GameObject go = Instantiate(infoItem, infoParent); go.GetComponent().Bind("状态:" + pinfo.startStopStatus); } { PLInfo pinfo = JsonConvert.DeserializeObject(info.timelyData.ToString()); GameObject go = Instantiate(infoItem, infoParent); go.GetComponent().Bind("状态:" + pinfo.faultStatus); } { PLInfo pinfo = JsonConvert.DeserializeObject(info.timelyData.ToString()); GameObject go = Instantiate(infoItem, infoParent); go.GetComponent().Bind("电源状态:" + pinfo.powerState); } { PLInfo pinfo = JsonConvert.DeserializeObject(info.timelyData.ToString()); GameObject go = Instantiate(infoItem, infoParent); go.GetComponent().Bind("描述:" + pinfo.descript); } { PLInfo pinfo = JsonConvert.DeserializeObject(info.timelyData.ToString()); GameObject go = Instantiate(infoItem, infoParent); go.GetComponent().Bind("楼层:" + pinfo.floor); } } gameObject.SetActive(true); } } public class PLInfo { public string deviceType; public string devInterface; public string startStopStatus; public string openProjectId; public string deviceTypeName; public string faultStatus; public string ulogtime; public int isOnline; public string deviceNo; public string deviceName; public string logTime; public string powerState; public string manualAutomaticState; public string devSystem; public string appKey; public string descript; public string floor; }