Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Suggestion: Ability to simulate a render to obtain TMP properties

Discussion in 'UGUI & TextMesh Pro' started by tomkail_betterup, Sep 2, 2022.

  1. tomkail_betterup

    tomkail_betterup

    Joined:
    Nov 17, 2021
    Posts:
    106
    Something we often need to do is get info about how TMP renders text; number of lines, number of characters items per line preferred size, rendered size, etc - but without actually rendering it! A common use case for us is trying different container sizes and seeing which creates the most aesthetic text layout - at Inkle, my previous company, I used this approach to find the best text layouts to fit in comic book style text bubbles.

    With the exception of GetPreferredSize (which can take a string and returns the size it WOULD like), TMP doesn't allow us to do this.
    Our solution up to now is to just use a TMP object, set our properties, add TextRenderFlags.DontRender and run ForceMeshUpdate. We then read the output we need and undo all those properties; which feels a bit hacky and is cumbersome.

    Would love to see a system for this one day!

    Ta!
     
    lcompton likes this.
  2. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    I realize this is an old post, but I agree. A method that would tell you the size of a string without having to actually set the text in the TMP component would be very useful.
     
  3. tomkail_betterup

    tomkail_betterup

    Joined:
    Nov 17, 2021
    Posts:
    106