using System.Collections; using System.Collections.Generic; using System.Linq; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Assertions.Must; using UnityEngine.Networking.Types; using UnityEngine.UI; public class JueseChoicePop : MonoBehaviour { public ClassMate classMate; public ClassItem classItem; public Button CloseBtn; public Button Surebtn; public GameObject classmatePrefab; public Transform content; public List classMateList = new List (); // 存储已实例化的 GameObject 列表 private List instantiatedObjects = new List(); public string s; public JSONReader jsonReader; public Panel panel; public WarningPopPanel WarningPopPanel; //Start is called before the first frame update void Start() { this.gameObject.SetActive(false); CloseBtn.onClick.AddListener(CLosePop); Surebtn.onClick.AddListener(CLosePop); //Surebtn.onClick.AddListener(SetFenguan); //SetClass(); } void Update() { } void CLosePop() { ClearAll(); this.gameObject.SetActive(false); } public void openPop() { this.gameObject.SetActive(true); } void SetFenguan() { //设置此区分的分管人员为用户选中的角色,并刷新界面信息 classItem.isSet = true; //classItem.setClassItem(); } //加载分管人员 public void SetClass() { //if (instantiatedObjects.Any(obj => obj.GetComponent().id == id)) //{ // Debug.Log($"这个: {id} 已经被实例化."); // return; // 如果已实例化,跳过 //} //foreach (Transform child in content) //{ // Destroy(child.gameObject); //} foreach(var all in panel.sceneDataDictionary) { foreach (var info in all.Value) { Debug.LogError("-------------------------"+ info.sceneId); LocationData locationData = jsonReader.GetAreaDateById(int.Parse(info.sceneId)); if (locationData.Oversee == "-1") { Debug.Log($"Skipping ID{info.sceneId}: Oversee is -1."); continue; // 跳过 } string[] overseeParts = locationData.Oversee.Split(','); string firstElement = overseeParts[0]; string lastElement = overseeParts[1]; if (overseeParts.Length > 0) { if(firstElement==info.dutyId&&lastElement=="1") { GameObject item = GameObject.Instantiate(classmatePrefab, content); ClassMate classMate = item.GetComponent(); Button button = item.GetComponent