Search Unity

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

    Another_Day

    Joined:
    Apr 23, 2022
    Posts:
    16
    Hello,

    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.

    Untitled.jpg

    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.