Compare commits

..

No commits in common. "1441e13a503c431d825ada5a38f974d4d7b83324" and "700c9ae420fbc6c789a6d4b5a78178f4310fa7b3" have entirely different histories.

3 changed files with 44 additions and 53 deletions

View File

@ -487,7 +487,7 @@ public class EvacuationPanel : Base
{ {
JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>(); JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
jueseChoicePanel.gameObject.SetActive(true); jueseChoicePanel.gameObject.SetActive(true);
jueseChoicePop.SetClass(classLevel.classname.text); jueseChoicePop.SetClass();
//jueseChoicePanel.SetClass(); //jueseChoicePanel.SetClass();
}); });

View File

@ -461,7 +461,7 @@ MonoBehaviour:
id: 0 id: 0
name: name:
classmatename: {fileID: 5469669078877023921} classmatename: {fileID: 5469669078877023921}
classText: {fileID: 646037399500158430} classText: {fileID: 0}
s: s:
otherButton: {fileID: 0} otherButton: {fileID: 0}
button: {fileID: 5469669078140634246} button: {fileID: 5469669078140634246}

View File

@ -20,8 +20,6 @@ public class JueseChoicePop : MonoBehaviour
public List<ClassMate> classMateList = new List<ClassMate> (); public List<ClassMate> classMateList = new List<ClassMate> ();
// 存储已实例化的 GameObject 列表 // 存储已实例化的 GameObject 列表
private List<GameObject> instantiatedObjects = new List<GameObject>(); private List<GameObject> instantiatedObjects = new List<GameObject>();
// 用于记录已加载的SceneId或者DutyId
HashSet<string> loadedSceneIds = new HashSet<string>(); // 或者使用字典来记录更多信息
public string s; public string s;
public JSONReader jsonReader; public JSONReader jsonReader;
@ -42,7 +40,7 @@ public class JueseChoicePop : MonoBehaviour
} }
void CLosePop() void CLosePop()
{ {
//ClearAll(); ClearAll();
this.gameObject.SetActive(false); this.gameObject.SetActive(false);
} }
public void openPop() public void openPop()
@ -57,63 +55,56 @@ public class JueseChoicePop : MonoBehaviour
} }
//加载分管人员 //加载分管人员
public void SetClass(string a) public void SetClass()
{ {
//if (instantiatedObjects.Any(obj => obj.GetComponent<ClassMate>().id == id))
//{
// Debug.Log($"这个: {id} 已经被实例化.");
// return; // 如果已实例化,跳过
//}
//foreach (Transform child in content)
//{
// Destroy(child.gameObject);
//}
foreach(var all in panel.sceneDataDictionary) foreach(var all in panel.sceneDataDictionary)
{ {
foreach (var info in all.Value) foreach (var info in all.Value)
{ {
Debug.LogError("-------------------------"+ info.sceneId); Debug.LogError("-------------------------"+ info.sceneId);
LocationData locationData = jsonReader.GetAreaDateById(int.Parse(info.sceneId)); LocationData locationData = jsonReader.GetAreaDateById(int.Parse(info.sceneId));
if (locationData.Oversee == "-1") if (locationData.Oversee == "-1")
{ {
Debug.Log($"Skipping ID{info.sceneId}: Oversee is -1."); Debug.Log($"Skipping ID{info.sceneId}: Oversee is -1.");
continue; // 跳过 continue; // 跳过
} }
string[] overseeParts = locationData.Oversee.Split(','); string[] overseeParts = locationData.Oversee.Split(',');
string firstElement = overseeParts[0]; string firstElement = overseeParts[0];
string lastElement = overseeParts[1]; string lastElement = overseeParts[1];
if (overseeParts.Length > 0)
if (overseeParts.Length > 0 && firstElement == info.dutyId && lastElement == "1")
{ {
Debug.LogError(loadedSceneIds.Contains(info.name));
// 如果已经加载过,跳过
if (loadedSceneIds.Contains(info.name))
{
Debug.Log($"Scene ID {info.sceneId} already loaded. Skipping.");
continue; // 如果该sceneId已经加载过就跳过
}
// 如果没有加载过,实例化预制体 if(firstElement==info.dutyId&&lastElement=="1")
{
GameObject item = GameObject.Instantiate(classmatePrefab, content); GameObject item = GameObject.Instantiate(classmatePrefab, content);
ClassMate classMate = item.GetComponent<ClassMate>(); ClassMate classMate = item.GetComponent<ClassMate>();
Button button = item.GetComponent<Button>(); Button button = item.GetComponent<Button>();
button.onClick.AddListener(() => button.onClick.AddListener(() =>
{ {
SetClassMate(classMate, a); //SetClassMate(classMate, );
}); });
classMate.name = info.name; classMate.name = info.name;
classMate.classmatename.text = classMate.name; classMate.classmatename.text = classMate.name;
// classMate.id = info.dutyId; //classMate.id = info.dutyId;
instantiatedObjects.Add(item); instantiatedObjects.Add(item);
// 将当前加载的sceneId添加到集合中
loadedSceneIds.Add(info.name);
} }
} }
} }
}
// 如果没有数据,弹出提示框 if(panel.sceneDataDictionary.Count==0)
if (panel.sceneDataDictionary.Count == 0)
{ {
WarningPopPanel.OpenPanel("请先添加对应的应急人员配置"); WarningPopPanel.OpenPanel("请先添加对应的应急人员配置");
} }
} }
//点击人员后设置位置的方法 //点击人员后设置位置的方法
public void SetClassMate(ClassMate classMate, string a = "") public void SetClassMate(ClassMate classMate, string a = "")
{ {