using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static UnityEditor.Progress; public class PersonnelPanel : MonoBehaviour { public Text personelPanelText; public Text personelNumText; public Text lockText; public Transform personelContent; public GameObject personelItem; public GameObject firstLablePrefab; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void CreatePeopleItem(List peopleList) { foreach (Transform child in personelContent) { Destroy(child.gameObject); } foreach (var personel in peopleList) { CreatePersonelItem(personel, personelContent); } } public void CreatePersonelItem(SelectedInfo person, Transform parentTransform) { // 实例化一个人员项并将其作为场景面板的子物体 GameObject item = Instantiate(personelItem, parentTransform); PersonnelInfo personnelItem = item.GetComponent(); personnelItem.nameText.text = person.name; // 设置姓名 } public void CreateSceneItem(SelectedInfo person, Transform parentTransform) { GameObject item = Instantiate(personelItem, parentTransform); PersonnelInfo personnelItem = item.GetComponent(); } public void OnClickBtn() { transform.gameObject.SetActive(false); } }