Rather unintuitively this is how it actually works.
You need to first make sure that your GameObject with the Horizontal Layout Group applied has Child Controls Size checked for “Width” and “Height”. You then need to have Child Force Expand “Width” = unchecked, “Height” = checked.
Locked Item: Needs a Layout Element script added to it.
-
Preferred width: set to the value you want.
-
Flexible Width: 0 (if it’s left at 1, it’ll just be flexible with 100 added to it and yes you have to check a box for “flexible” when you want it to not be flexible)
Flexible Item: Needs a Layout Element script added to it.
- Flexible Width: 1
If you leave the Flexible Width off, it will just collapse the button’s width.
The results are consistent once you get the hang of it, but the problem is bending your head to click on all the different settings with names that don’t fit to get the right numbers.
Be careful if you’re going to use this for a Vertical group to set Child Force Expand “Width=checked” and “Height=unchecked” on the layout group
