using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static Manager; public class DianLiItem : MonoBehaviour { public JiLongItem item1; public JiLongItem item2; public Text sname; public Text zgl; public Text srdl; public int index; ServerRoomData srd; public static List jiLongItems = new List(); public void updateData(ServerRoomData srd,int i) { this.srd = srd; index = i; sname.text = srd.name; zgl.text = srd.zonggonglv.ToString("F2")+"kW"; srdl.text = srd.shangridl.ToString("F2") + "kWh"; if(index==0) { choose(true); } } public void choose(bool b) { if(b) { for (int i = 0; i < jiLongItems.Count; i++) { Destroy(jiLongItems[i].gameObject); } jiLongItems = new List(); DataManager.Instance.GetJL(this.srd.id, (data) => { for (int i = 0; i < data.Count; i++) { JiLongItem fz; if (data[i].jiguilist.Count > 2) { fz = GameObject.Instantiate(item2, item2.transform.parent); } else { fz = GameObject.Instantiate(item1, item1.transform.parent); } fz.gameObject.SetActive(true); fz.updateData(data[i]); jiLongItems.Add(fz); } }); } } }