_xiaofang/xiaofang/Assets/Script/UI/PanelUI/PersonnelPanel.cs
2024-12-01 15:06:22 +08:00

47 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PersonnelPanel : MonoBehaviour
{
public Text personelPanelText;
public Text personelNumText;
public Transform personelContent;
public Panel panelInfo;
public GameObject personelItem;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void CreatePeopleItem(List<SelectedInfo> 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<PersonnelInfo>();
personnelItem.nameText.text = person.name; // 设置姓名
}
public void OnClickBtn()
{
transform.gameObject.SetActive(false);
}
}