I am creating a “backpack” UI and I need to change the number of child elements of the ScrollView.
But it is a bit strange that the ScrollView does not automatically refresh to the right height.
As you can see from the image below, I only have three items, but the ScrollView has a long height.
I wonder if there is something wrong with my code writing?
Please help me, thank you very much.
void Refresh() {
ScrollView d_scroller = root.Query<ScrollView>();
// Clear existing elements
d_scroller.Clear();
// Adding new elements according to the list
for (int i = 0; i < lists.Count; i++) {
VisualElement em = new VisualElement();
d_scroller.Add(em);
}
}