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"; zgl.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(); for (int i = 0; i < this.srd.jilonglist.Count; i++) { JiLongItem fz; if (this.srd.jilonglist[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(this.srd.jilonglist[i]); jiLongItems.Add(fz); } } } }