- Home /
Nested Content Size Fitters
Hi I want to use a structure of nested Panels and other UI Components and use Content Size Fitters for scaling. For one Panel the Content Size Fitter works but when I use one in a sub panel it doesn't.
Is it even possible to use multiple content size fitters on sub elements?
My UI should look something like this:
Main Panel with content size fitter and Vertical Layout -> Multiple Subpanels with Grid Layout and content size fitter -> UI Elements inside the panels.
Answer by sarahnorthway · Aug 28, 2018 at 04:12 AM
My nested ContentSizeFitters display a warning about having a parent with a layout group component, however the layout works correctly in Unity 2018.2. My layout is:
ContentSizeFitter (vertical Preferred) + VerticalLayoutGroup (all zeroes no checkboxes)
-> ContentSizeFittrer (vertical Preferred) + VerticalLayoutGroup (child controls size Height)
--> Text
-> ContentSizeFittrer (vertical Preferred) + VerticalLayoutGroup (child controls size Height)
--> Text
-> ContentSizeFittrer (vertical Preferred) + VerticalLayoutGroup (child controls size Height)
--> Text
Gotcha that got me: Even if you only want a single nested item with zero padding, the top level ContentSizeFitter will not work (height 0) unless it also has a VerticalLayoutGroup.