I’ve got a default Scrollview (620x800) with a permanent vertical scrollbar. Default Viewport.
My Content parent starts at 603x2000 in size and has a Vertical Layout Group element (only left padding and Upper Left alignment).
All my UI elements are children is the Content.
I want to replace text at runtime and have the layout resize automatically (Vertical only) based on the new content.
For some reason I cannot get it to working. I tried the Content Fitter but couldn’t get it right. I tried LayoutRebuilder.ForceRebuildLayoutImmediate in code after updating the text element (also tried waiting one frame), no luck.
Strip down the problem, the layout stuff is finicky, but it does work. Sometimes you have to flip the object active / inactive a few times to get it to lay out.
For instance, enclosed is an expanding cartoon bubble. Study how it is set up and apply that to your situation.
Here are the official docs on how to make your UI handle various resolutions and aspect ratios cleanly:
Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:
Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings you will often need to redo your UI entirely.