Search Unity

Unity UI Horizontal Layout Group doesn't change width and height of child elements

Discussion in 'UGUI & TextMesh Pro' started by Kaes3kuch3n, Jul 25, 2017.

  1. Kaes3kuch3n

    Kaes3kuch3n

    Joined:
    Jul 21, 2017
    Posts:
    3
    I've created a Panel with a Horizontal Layout Group with Child Force Expand Width and Height checked.
    The Panel has two Buttons as children.
    Now I want each button to scale up to half the size of the panel, so that they are equally sized and there's no free space left on the panel. But Unity doesn't seem to control the width and height and only changes the position of the buttons. While the buttons are positioned right, they aren't scaled to fill up the empty space.
    I tried adding a Layout Element to the buttons and setting the preferred width to half the panel width and the height to the panel height, bu that didn't seem to work either.
    What am I doing wrong?

    Panel:

    Button 1:

    Button 2:
     
  2. Kaes3kuch3n

    Kaes3kuch3n

    Joined:
    Jul 21, 2017
    Posts:
    3
  3. Kaes3kuch3n

    Kaes3kuch3n

    Joined:
    Jul 21, 2017
    Posts:
    3
    Okay, I figured it out. I had to check the boxes for child controls size, too.
    The Unity reference needs a little update :)

    #closed
     
  4. dizzy_man667

    dizzy_man667

    Joined:
    Sep 8, 2018
    Posts:
    1
    Thanks
     
    sumitbabucutevil likes this.
  5. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Right, stupidly,

    when you select "Child Force Expand"

    you have to ALSO select "Child Controls Size".

    "Child Force Expand" is meaningless unless "Child Controls Size" is ticked.

    It's stupidity, it's Unity.
     
  6. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    150
    Anyone had problem while uncheck and width & height cannot be edit anymore?
     
    AmazinJacks and sumitbabucutevil like this.
  7. louqianceng

    louqianceng

    Joined:
    Oct 24, 2018
    Posts:
    1
    Does Anyone know how to read the cell's position when the it's locked (at least you cannot modify it)?
     
  8. AmazinJacks

    AmazinJacks

    Joined:
    Oct 22, 2019
    Posts:
    9
    Yes. From what I can tell, checking the Child Controls Size boxes on the Vertical/Horizontal Layout Group component changes the width & height settings inside the child objects (buttons).

    Unchecking the boxes does not reset those sizes, you have to manually open each child and reset the sizes yourself.
     
  9. Progabo

    Progabo

    Joined:
    Apr 2, 2020
    Posts:
    1
    Man I had basically the same issue and I didn't know why :S
    Thank you
     
  10. RSH1

    RSH1

    Joined:
    Jul 9, 2012
    Posts:
    256
    Do you mean "Child Force Expand" and "Control Child Size"?

    Don't they do opposite things?

    upload_2024-1-18_14-4-16.png
     
  11. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    hiya @RSH1 look at the question at top of page and look at the first gray image labelled "Panel". "Child controls size"

    Note that this QA is ~10 yrs old. Unity drastically and constantly changes how stuff works, usually leading to even more problems. I have no idea on the latest on this issue. What was written here at the time was correct. Best of luck!
     
    Jilbarkus likes this.