thanks chatgpt, I don't even know what was wrong 💀

This commit is contained in:
2025-10-18 10:22:09 -07:00
parent 0ece6b9b3f
commit 75123d8312

View File

@@ -407,10 +407,17 @@ public class ChatroomMenu : MonoBehaviour
} }
obj.SetSiblingIndex(i); obj.SetSiblingIndex(i);
} }
if (content.transform.childCount > 50) int activeCount = content.transform.Cast<Transform>().Count(t => t.gameObject.activeSelf);
if (activeCount > 50)
{ {
var firstChild = content.transform.GetChild(1); int toRemove = activeCount - 50;
Destroy(firstChild.gameObject); foreach (Transform item in content.transform)
{
if (!item.gameObject.activeSelf) continue;
Destroy(item.gameObject);
toRemove--;
if (toRemove <= 0) break;
}
} }
var rowInfo = Instantiate(sampleObject, content.transform); var rowInfo = Instantiate(sampleObject, content.transform);
@@ -483,10 +490,9 @@ public class ChatroomMenu : MonoBehaviour
{ {
foreach (Transform item in content.transform) foreach (Transform item in content.transform)
{ {
if (item.gameObject.activeSelf) if (!item.gameObject.activeSelf) continue;
{ Destroy(item.gameObject);
Destroy(item.gameObject); break;
}
} }
} }
if (shouldScrollToBottom) if (shouldScrollToBottom)