using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class RescueTeamManager : MonoBehaviour { public GameObject itemPre; public List teams = new List(); //获取所有正在营救的中队 public static event Func, List> getAllRescueTeams; void OnEnable() { teams = new List(); if(getAllRescueTeams != null) { teams = getAllRescueTeams(teams); } CreateTeams(); } public void CreateTeams() { if (itemPre == null) { itemPre = Resources.Load("RescueInfo/RescueTeamItem") as GameObject; } for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } foreach(string team in teams) { GameObject item = Instantiate(itemPre, transform); item.GetComponent().Set(team); } } // Use this for initialization void Start () { } // Update is called once per frame void Update () { } }