I’ve asked this on Unity answers but not sure which place gets more traffic.
I want to create UI text elements with backgrounds that resize to fit around the text. I’ve tried to follow guides which use vertical layout groups to achieve this. What I have at the moment partially works. The image and text resize as more text is added. But the height of the background image won’t shrink below 110 (see top text).
I can see that the preferred height of the background image is 110, but I’m not sure what determines this. When I try using a LayoutElement to change the Preferred Height, this breaks the auto-resizing behaviour that I want.
If I use a LayoutElement on the image with Preferred Height set:
The UI hierarchy is:
Contents Container and Heading Background have a VerticalLayoutGroup components with settings:
Does anyone know how I can change the preferred height of the background image while still having the background+text autosize to fit the text? Thanks!