[4.6] Auto grow/shrink a panel to fit its contents

Hi there,

I’m trying to create a UI panel that automatically grows and shrinks based on its contents. (which are dynamic)
Right now I have a panel set up with a vertical layout group in order to fit the Text objects inside of it, but I would like to have the main panel expand as it gets more text fields.

Is there a component for this or do I have to do it by code?

Are you after the ContentSizeFitter?

Check out this tutorial. There is a follow up tutorial linked at the end of the video that shows how to do it via script.

try this, it’s not perfect as resolution changes need fixing but it works fine if you have a set resolution.

YouTube Tutorial