ListView clipping contents

I have an Editor class with a ListView component. I’d like to have the ListView expand to its full size, so that I can see all of the children.

For some reason, the ListView is as small as minHeight allows, no matter how large the children are. UIElements debugger showed that there are two places where the size gets clipped: first in ScrollView, then again in the ListView that contains it.
Fiddling with flexGrow and flexShrink didn’t help - the clipping still happens.

Is there a way to get the ListView (and the ScrollView it creates for itself) to expand to cover all the children, other than hacking it with scripts?

If you want to display all elements, then a ListView is probably not the thing you need. A simple PropertyField over an array property will display the entire array inside a foldout.

Now if what you want is a ListView that expands if there is still space in the inspector, now that’s something that not doable without code at this moment. You might want to report an issue with Help->Report a bug and provide screenshots of what you’d expect vs what you’re seeing.

My list’s children depend on the parent for display - children are just key-value pairs, where keys are from a (non-static) set known to parent.
Essentially equivalent to this:

class Parent {
  List<KeyValuePair<string, bool>> list;
  HashSet<string> possibleKeys;
}

Is PropertyField still good for this?

I guess you’d want each item key to be shown as a dropdown. In this case the PropertyField won’t help you I’m afraid unless you go with a custom drawer for a custom KeyValuePair equivalent type.

Check for the ArrayInspectorElement in this post:

2 Likes