Puzzled by VerticalLayoutGroup puzzle

Here’s what I’m trying to do: Have a panel that contains 3 panels stacked vertically. The top and bottom panels have a fixed size, and the middle panel needs to autoexpand to fill in the space in the middle.

However, for the life of me, I can’t quite figure out how to get this to work using Unity UI.

Here’s what I’ve tried so far:

Container panel: Add a vertical layout group. Child control size and force expand for width is checked. Height is left unchecked.

Top panel: Add a layout element, set min and preferred height to 128.

Bottom panel: Add a layout element, set min and preferred height to 128.

Center panel: ??? I’m stuck here.

I’m about ready to throw in the towel, and just stick a script on the center panel to set its height by subtracting 256 from the container panel’s height, but that feels hacky to me.

Am I missing something obvious?

OK yes I was missing something obvious: Just get rid of the VerticalLayoutGroup :smile:

I solved this by anchoring the top panel to top with horizontal stretch. Bottom panel anchored to bottom with horizontal stretch.

Then I set the center panel to fill with an offset from top and bottom by their heights. It’s not ideal as I’d have preferred this to be fully automatic, but I couldn’t see any other way.