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

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:

1 Like

#push

Okay, I figured it out. I had to check the boxes for child controls size, too.
The Unity reference needs a little update :slight_smile:

closed

5 Likes

Thanks

1 Like

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.

5 Likes

Anyone had problem while uncheck and width & height cannot be edit anymore?

2 Likes

Does Anyone know how to read the cell’s position when the it’s locked (at least you cannot modify it)?

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.

Man I had basically the same issue and I didn’t know why :S
Thank you

Do you mean “Child Force Expand” and “Control Child Size”?

Don’t they do opposite things?

9589537--1358653--upload_2024-1-18_14-4-16.png

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!

1 Like