fix: Fix incorrect iteration when destroying game objects

This commit is contained in:
2025-02-17 17:16:27 +08:00
parent 35b77b044c
commit a0ded872b3

View File

@@ -7,11 +7,10 @@ namespace Cryville.EEW.Unity.UI {
EventUnitView m_prefabEventUnitView; EventUnitView m_prefabEventUnitView;
public void Set(ReportGroup group) { public void Set(ReportGroup group) {
foreach(Transform child in transform) { foreach (Transform child in transform) {
child.SetParent(null, false);
Destroy(child.gameObject); Destroy(child.gameObject);
} }
foreach(var unit in group) { foreach (var unit in group) {
Add(unit); Add(unit);
} }
} }