using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ArrivedForceContent : MonoBehaviour { public GameObject itemPre; /// /// 创建到场力量显示条目 /// /// public void CreateItems(Dictionary>> arrivedCars) { for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } if (itemPre == null) { itemPre = Resources.Load("ArrivedForce/ArrivedForceItem") as GameObject; } foreach(string team in arrivedCars.Keys) { List> list = arrivedCars[team]; foreach(KeyValuePair pair in list) { for(int j = 0; j < pair.Value; j++) { GameObject item = Instantiate(itemPre, transform); item.GetComponent().Set(team,pair.Key, j); } } } } public void CreateItems(List trucks) { for(int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } if (itemPre == null) { itemPre = Resources.Load("ArrivedForce/ArrivedForceItem") as GameObject; } foreach(TruckMessage msg in trucks) { GameObject item = Instantiate(itemPre, transform); item.GetComponent().Set(msg); } } }