Search Unity

Disable wrapping, but only for single words?

Discussion in 'UGUI & TextMesh Pro' started by jlanisdev, Dec 14, 2020.

  1. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    Is there any way in TMP to disable wrapping, but only for single words? For example, let's say I have the following text:

    "ThisIsAVeryLongWord"

    Since there's no spaces, I would like auto-scale the text to fit the boundaries so it can fit on one line. However, If I have this text:

    "This Is A Very Long Sentence"

    I do not want to scale the text; I simply want it to overflow onto the next line.

    It seems like this is an either/or scenario: there is no way to have both. Is that true?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There is not.

    What is the use case for this?
     
  3. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    I have some UI where I want to display a name of something dynamically within a certain rect. I prefer the text to be the same size no matter what is displayed, except for the case when a word is too long, in which case scaling the text is the only option. Otherwise it would look like:

    ThisIsAVeryLongWo
    rd

    which obviously should never happen