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);
}
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);
Destroy(firstChild.gameObject);
int toRemove = activeCount - 50;
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);
@@ -483,10 +490,9 @@ public class ChatroomMenu : MonoBehaviour
{
foreach (Transform item in content.transform)
{
if (item.gameObject.activeSelf)
{
Destroy(item.gameObject);
}
if (!item.gameObject.activeSelf) continue;
Destroy(item.gameObject);
break;
}
}
if (shouldScrollToBottom)