Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Getting objects to stretch in a horizontal layout group

Discussion in 'UGUI & TextMesh Pro' started by batvink, Dec 29, 2023.

  1. batvink


    Sep 26, 2019
    I have tried every combination of Horizontal Layout Group (HLG) and Layout Element settings I can think of, and have failed miserably to get a number of buttons (contained in a prefab) to stretch as I would like.

    Here is my setup: a Vertical Layout Group with 3 Game Objects. The third is a HLG with up to 4 Prefab buttons.


    In code, I show between 2 and 4 buttons. The buttons spread out as expected across the HLG. But the size doesn't change. When I look at the widths, the prefab holding the button stretches as expected. But the button in the prefab doesn't resize.

    The prefab has a Layout Element with Flexible Width enabled. The button also has a Layout Element with Flexible Width enabled.

    What is the correct way to set this up?


    Question Layout = Vertical LG
    ViewQuestionAnswers = HLG