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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

TextMesh Pro TMP.SetArraySizes causes massive resource spike on initial apperance.

Discussion in 'UGUI & TextMesh Pro' started by Another_Day, Apr 15, 2023.

  1. Another_Day


    Apr 23, 2022

    I have a single TMP text object that I use for displaying information to the screen. The first time this message is made visible there is some harsh stutter in the game. The profiler points to TMP Parse Text and TMP.SetArraySizes as the culprits, with quite a lot of garbage being generated.


    Other posts online talk about why this happens, the buffer needs to be dynamically expanded once enough text is trying to be displayed. This makes sense, however, I cannot find a way to set that buffer myself in code. SetArraySizes() is not an accessible method, even if you use reflection it expects a private data type.
    Is there really no way to just set the buffer myself to size X in a monobehaviour and call it a day?

    I can post the textmesh component if needed, but all the usual "gotchas" like auto size are turned off and I'm using the default Liberation font. As previously stated this only happen the very first time a text message is displayed on the screen. All later instances are fine even if the text in the TMP object is updated at runtime to be shorter/longer.
    GuirieSanchez and Seb-1814 like this.