[UIBuilder] ListView sizing problem

Hello Unity community!

I’m trying to make a simple EditorWindow with a ListView in it. I’m having trouble with the sizing of the ListView. I want it to take all of the remaining space in the EditorWindow, but it doesn’t work… Furthermore, as soon as the ScrollBar appears, it starts overlapping with the buttons at the top of the EditorWindow, which is even worse than the empty space. Here is an image showing the behavior :

7905874--1007647--ListViewSizingProblem.png

The thing is, everything looks fine in the UIBuilder, but as soon as I open the real EditorWindow, the above behavior happens.

Any idea why this is and how to fix it? The top buttons are fixed in height (30px), but even if I set the height to auto and compensate with padding, when the scrollbar appears the buttons shrink to make way to the ListView…

Any help would be very appreciated!

Thanks!

You probably have a container as parent for your two buttons that needs to have the flex-shrink value to 0 to prevent them shrinking.

Then for the list view itself, assigning a flex grow value would tell it to fill all available space.

Maybe the discussion would be more efficient/precise if you share your uxml/uss with us?

1 Like

Hi Simon!

Thanks for your reply!

I played around with the Shrink and Grow values and it fixed my issues! I’m fairly new to unity and didn’t quite understand what these values were meant to do, so thank you for making me look into them!

Have a nice day!

1 Like

You can get a lot of inspiration from the web (CSS flexbox). The flex system is really powerfull, but not much intuitive.

I’ll be sure to look into this! Thank you!