Child Controls Size

In the Vertical Layout Group component there are settings titled “Child Controls Size” (immediately below Child Alignment). What do these settings do? These settings are absent from the manual (Redirecting to latest version of com.unity.ugui), which doesn’t show them at all. I am using Unity 2017.1.0f3, recently migrated from Unity 2017.1.0b5 (among others).

2 Likes

I’m also wondering this. I used the UI system in Unity 4.6 while working at a game studio, and had a fairly thorough understanding of it - I came back to Unity 5.5 looking to put together a side project, and suddenly half the layout setups I was familiar with weren’t working any more. I gave up, and today opted to check out Unity 2017.1, and while things appear to have improved, I was disappointed to see confusing settings like “Child Controls Size” with no documentation. Even worse, it appears to do the opposite of what you’d expect; when I turn it on, the child objects stop controlling their size, and the layout group takes over.

3 Likes

Ping on this as well, though I think this should have been posted in the Unity UI forum.

No documentation on these settings, and searching the internet it doesn’t look like any clear discussion on what they do either.

1 Like

I’m confused too.

Unity team, what does this do?

I also would like to know this.

Hey Unity, any tips on this parameter?

I think when you check “child controls size” you say “size of each element is now controlled by LayoutElement component”, and those without LayoutElement component attached become zero-sized. If “child controls size” is unchecked you are free to set any size while no other setting set them sized in some way, for example “child force expand” - overrides other checks and set elements to max possible size

Maybe the settings for this should’ve been inversed, or the setting named “control child’s size” instead? Looks like there’s already a feedback item on this.
https://feedback.unity3d.com/suggestions/layout-group-components-child-controls-size-inverted
Stupid that people should have to “vote” on something as simple as a name change or actually correcting a setting on something so simple…

1 Like

child controls size means the children will control the size of the layout group. This can be modified by a layout element, too.

For example, I tested a simple example with this setup:
a panel + a vertical layout group with the 2 options for child control size on and the others off.
then i added a button.
Immediately, the button is super small.
I added a vertical layout group to the button with the same settings, as above, and then the button grew (based on the Text child game object).

  • using a layout element, instead of the last step, you could get other results :slight_smile:
1 Like

The Layout group system is … hilarious.

It is

- so bad
- so broken
- so misnamed

it could only happen at Unity.

It’s a fantastic example of the “Unity way” - you have something that could be incredible, but it has utterly, totally, incompetent basic errors.

Any - that’s any - programmer at Unity could fix this in a few hours. It’s been fucked-up for 4? years?

(It goes without saying the doco is as utterly hilarious. You just couldn’t make up stuff like this. But that’s Unity.)

14 Likes

It’s working fine for me actually. I’m using this to set up a chat system. Basically, you’ll set the minimum size of the text (background) prefab. Then with child controls size, each text line background will expand or shrink to wrap the entered text.

My only problem is that, even though the text background is working fine, the frame to wrap those lines cannot limit how much each line can expand. If any one knows how to fix this, please let me know.

I stumbled into this same area recently and was left baffled. In the end, I found a guide that helped out a lot… Unity UI Layout Groups Explained | Hallgrim Games Blog

Some of the wording is a little unclear but nuggets of information like the LayoutElement component (and values defaulting to 0) helped a lot.

1 Like

It seems to do exactly the opposite of what the name suggests, and the manual confirms it.

From the manual:

Child Controls Size Whether the Layout Group controls the width and height of its children.

Child controls size” makes me imagine that, by checking those boxes, the size setting on the children element will take precedence over the layout group size.

But, in fact, the correct name would be “Control child size” or something like that.

I have to say that every single day that I spend with the LayoutGroup system, I find some weird thing like this. The system could really use some better labelling, at the very least.

2 Likes

As I wrote in my article (btw., thanks for posting it here :slight_smile: ), the "Child Controls Size" name does make sense, but only when you learn that there are by-default hidden layout properties of the children that are being referred to. You can set these properties, which default to 0 unfortunately, by adding a Layout Element on the children and setting preferred/min/relative sizes.

I summarised this in the above linked blog post :slight_smile:

1 Like

cheers, this should really be part of the official documentation.

I had this problem where I wanted to resize the parent panel of a text and a button using Content Size Fitter and Vertical Layout Group, however the button was being smashed as you described. Thanks to your info, adding Vertical Layout Group to the button (with Child Control Size on and some Padding) made it work.
I’m replying and describing this process so people might find this and solve this as it might be a common question which we can’t properly search for.

I’m uploading some images to describe visually how to proceed.
The final result is that by clicking on the Ok button, a script would change the text and the panel would resize itself.

I image the “problem” was the Child Control Size was resizing the Text component, or something along these lines.
Thanks for sharing your knowledge, methos5k o/

3993109--343849--Panel2.png
3993109--343852--Panel1.png
3993109--343855--BeforeClickingOk.png
3993109--343858--AfterClickingOk.png

Excellent work. The option is now named “Control Child Size” in Unity. You done went and made change happen!

2 Likes

I think this should be called “Child Size Controlled By LayoutSystem”

2 Likes