Search Unity

Bug HorizontalLayoutGroup's "Control Child Size" only accounts for child scale on width, not height

Discussion in 'UGUI & TextMesh Pro' started by Ultroman, Jun 22, 2020.

  1. Ultroman

    Ultroman

    Joined:
    Mar 10, 2014
    Posts:
    110
    As the title says...
    HorizontalLayoutGroup's "Control Child Size" only accounts for child scale on width, not height, even when "Use Child Scale" (Height) is ticked.
    Is this intended behaviour? Am I missing something?
    Here are some screenshots to show what's happening, NOT in "Play Mode", so it should update when I change variables. Should my Text's RectRansform, which has scale 0.1 on both x and y, not get its height set to 300, since its parent is 30 tall, just like the width of 120 on the parent is correctly translated to 1200 on the child?

    UPDATE: VerticalLayoutGroup does the same thing, but reverse, so it doesn't use the child scale on the width, even when "Use Child Scale" (Width) is ticked.

    Parent, with HorizontalLayoutGroup:
    upload_2020-6-22_2-41-22.png

    Child of parent that has HorizontalLayoutGroup:
    upload_2020-6-22_2-42-41.png

    ------------------------------------------------------------

    Parent, with VerticalLayoutGroup:
    upload_2020-6-22_3-4-43.png


    Child of parent that has VerticalLayoutGroup:
    upload_2020-6-22_3-5-35.png


    Workaround:

    Put a "Layout Element" component on the child, and set its "Minimum Width" to the width you want it to be. It's annoying to have to do this. It limits the versatility of the child.

    I actually think this behaviour is the root of several of my problems with the UI system. Particularly because the standard Text element looks so bad with default settings, so you have to scale it down and then raise the Font Size accordingly, in order to have crisp text (or work with TextMeshPro). And now I have this dumb problem that my huge, scaled down Text is nice and wide, but only 10% as tall as it should be. All because I want to let the layout and size of my buttons be determined further up the parent-chain, which works fine, except for this scale-problem. Even if I used TextMeshPro or just an Image as the child, it still does the same thing when the child is scaled in any way.
     
    Last edited: Jan 8, 2021