Search Unity

TextMesh Pro Text Footprint Not Calculating Properly with Layout Group, Auto Size, and Wrapping

Discussion in 'UGUI & TextMesh Pro' started by calvin-tl, May 31, 2019.

  1. calvin-tl

    calvin-tl

    Joined:
    Jul 18, 2017
    Posts:
    4
    We've been struggling for a little while with TextMesh Pro objects that are set to Auto Size and Wrap while inside a Layout Group.

    I'll illustrate the issue with a simple example.

    This is the Layout Group that contains the text:


    These are the TextMesh Pro settings:


    And here's what happens when you enter a long string of unbroken text:

    You can see that the yellow footprint is much larger than is needed for the text.

    Here you can see how this can screw up the alignment when you have multiple text objects that are supposed to be centered within the gray square:

    It looks like all the text is being shoved to the top of the containing square. If I were to add a few more characters, the text would start wrapping into that extra space but the problem would repeat on the next line.

    It looks like it is calculating the vertical space required as if Auto Size was not enabled, but then Auto Size kicks in and reduces the text size, removing the need for the text to wrap, but leaving the space that was created to accommodate.

    Anyway, any help would be greatly appreciated!
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What version of TextMesh Pro and Unity are you using?

    Is the object that contains the Vertical Layout Group a parent of the text object?

    Can you post an image of the RectTransform of this parent object?
     
  3. calvin-tl

    calvin-tl

    Joined:
    Jul 18, 2017
    Posts:
    4
    Hey Stephan, we're on Unity 2017.1.5f1 and it looks like TextMesh Pro 1.0.54.

    Yeah, the Vertical Layout Group is the direct parent of the text objects, so the hierarchy looks like this:
    • VerticalLayout
      • TextMeshPro Text
      • TextMeshPro Text(1)

    And this is VerticalLayout's Rect Transform:

    Nothing fancy there for the demonstration.

    Thanks for your help, really appreciate it!
     
  4. calvin-tl

    calvin-tl

    Joined:
    Jul 18, 2017
    Posts:
    4
    Any thoughts on this? Maybe this was fixed in a newer version? I wasn't able to find a reference in the change logs but maybe I missed it.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Please re-test with the latest release of TMP which would be in Unity 2018.4 with version 1.4.1 or 2019.1 with version 2.0.1.

    Don't convert your project, just re-test the above as I have made a lots of changes / fix since version 1.0.54.