Search Unity

TextMesh Pro How do I remove spacing from TextMeshPro UI

Discussion in 'UGUI & TextMesh Pro' started by ChadrickEvans, Jul 22, 2021.

  1. ChadrickEvans

    ChadrickEvans

    Joined:
    Mar 14, 2015
    Posts:
    46


    This only happens when the next word is assumed to be incredibly long. This only happens with the UI version of TextMeshPro as far as I know.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Looks like you are using Justified text alignment where spacing between words and characters (subject to the Wrap Mix setting) will add additional space to justify the text as seen below.

    upload_2021-7-22_19-39-30.png

    When using Justified alignment, all lines with the exception of the last one will be justified.

    Since the text in your example doesn't fit on a single line and only contains one space, the super long word wraps to the 2nd line. Since we do have text on the first line, the spacing between characters is adjusted to make it justified / flush with the left and right margin. Then since the super long word doesn't fit on a single line, it is the split per character which is why you end up with the "g" on the third line.

    The above behavior is by design. I am not sure if you meant to use Justified text alignment or not. If so, this mode is definitely not ideal with short sentences or with text similar to what you are using in your example.

    Having said that, what is your expectation as per your example / use case?
     
  3. ChadrickEvans

    ChadrickEvans

    Joined:
    Mar 14, 2015
    Posts:
    46
    I was looking to have the text behave the same way it does in the non-UI version. Even if the first word is 4 characters long and the next word is 15 characters long. To me, it's fine if it wraps around to the next line leaving the shorter word by itself on top.

    Is there a way to remove justified alignment so there's no spacing for words with less characters?
     
  4. ChadrickEvans

    ChadrickEvans

    Joined:
    Mar 14, 2015
    Posts:
    46
    Well, ignore the previous question haha.

    It seems my unfamiliarity with the asset caused me more confusion than necessary. The button was in plain sight all along.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Just for thoroughness and potentially other users running into this, here are the text alignment options.

    upload_2021-7-23_12-36-53.png