上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

12 months ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DeviceBind : MonoBehaviour
{
public DeviceType BindType;
public List<DeviceList> Binddata;
public Transform BindParent;
public GameObject BindePrefab;
public Text Title;
public Button CloseBtn;
public void DataBind(DeviceType bindType, List<DeviceList> binddata, string bindobj = null)
{
Title.text = bindType.ToString() + "列表";
Binddata = binddata;
BindType = bindType;
foreach (Transform item in BindParent)
{
if (item.name != "None")
{
Destroy(item.gameObject);
}
}
foreach (var item in binddata)
{
GameObject go = Instantiate(BindePrefab, BindParent);
Color showColor = Color.white;
foreach (var de in DevicePanelManager.Instance.BindObjectList)
{
if (!string.IsNullOrEmpty(de.ObjName))
{
if (de.DeviceId == item.deviceNo)
{
if (de.ObjName == bindobj)
{
showColor = Color.red;
}
else
{
showColor = Color.yellow;
}
break;
}
}
}
go.GetComponent<DeviceItem>().DataBind(item, showColor);
}
if (binddata.Count == 0)
{
BindParent.Find("None").gameObject.SetActive(true);
}
else
{
BindParent.Find("None").gameObject.SetActive(false);
}
gameObject.SetActive(true);
}
void Start()
{
CloseBtn.onClick.AddListener(() =>
{
gameObject.SetActive(false);
});
}
}