Search Unity

Child Controls Size

Discussion in 'Editor & General Support' started by AbleArcher, Jul 17, 2017.

  1. AbleArcher

    AbleArcher

    Joined:
    Feb 27, 2017
    Posts:
    9
    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 (https://docs.unity3d.com/Manual/script-VerticalLayoutGroup.html), which doesn't show them at all. I am using Unity 2017.1.0f3, recently migrated from Unity 2017.1.0b5 (among others).
     
    Acoustic125 and christophermrau like this.
  2. Bixbite

    Bixbite

    Joined:
    Nov 1, 2012
    Posts:
    12
    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. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    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.
     
    christophermrau likes this.
  4. jeremytm

    jeremytm

    Joined:
    Jun 6, 2016
    Posts:
    30
    I'm confused too.

    Unity team, what does this do?
     
  5. wusticality

    wusticality

    Joined:
    Dec 15, 2016
    Posts:
    71
    I also would like to know this.
     
  6. christophermrau

    christophermrau

    Joined:
    Mar 16, 2017
    Posts:
    5
    Hey Unity, any tips on this parameter?
     
  7. apelsinex

    apelsinex

    Joined:
    Dec 19, 2016
    Posts:
    2
    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
     
  8. TheDemiurge

    TheDemiurge

    Joined:
    Jul 26, 2010
    Posts:
    42
    Fattie likes this.
  9. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    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 :)
     
    Markzs17 likes this.
  10. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    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 F***ed-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.)
     
  11. Jenny89

    Jenny89

    Joined:
    Apr 3, 2018
    Posts:
    1
    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.
     
  12. mark_cb

    mark_cb

    Joined:
    Jun 9, 2015
    Posts:
    17
    Halgrimmur likes this.
  13. VBenincasa

    VBenincasa

    Joined:
    Feb 13, 2014
    Posts:
    12
    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.
     
    a436t4ataf and khalvr like this.
  14. Halgrimmur

    Halgrimmur

    Joined:
    Jul 15, 2014
    Posts:
    1
    As I wrote in my article (btw., thanks for posting it here :) ), 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 :)
     
    Finer_Games likes this.
  15. Finer_Games

    Finer_Games

    Joined:
    Nov 21, 2014
    Posts:
    33
    cheers, this should really be part of the official documentation.
     
  16. Markzs17

    Markzs17

    Joined:
    Nov 21, 2018
    Posts:
    4
    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/
     

    Attached Files:

  17. LordFlufflebuns

    LordFlufflebuns

    Joined:
    Jan 10, 2019
    Posts:
    4
    Excellent work. The option is now named "Control Child Size" in Unity. You done went and made change happen!
     
    michaelday008 and Nition like this.
  18. ookk47oo

    ookk47oo

    Joined:
    Mar 17, 2017
    Posts:
    80
    I think this should be called "Child Size Controlled By LayoutSystem"
     
    Flavelius and NoooneyDude like this.