Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    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


    Nov 17, 2021
    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!