Search Unity

Question Lag spike when enabling large amount of TextMeshProUGUI objects

Discussion in 'UGUI & TextMesh Pro' started by noam_2000, Oct 29, 2021.

  1. noam_2000

    noam_2000

    Joined:
    Sep 14, 2017
    Posts:
    18
    Hi everyone,

    I have a situation where in a certain menu, I need to have a long, scrollable list of entries (~100), with each entry containing 2 text mesh pro UI components.

    However, whenever this menu is enabled, I experience a lag spike that I really wish was not there, and from debugging, seems to be caused purely by TMP.



    For reference, both TMP items in each entry contain a short sentence, and each entry only needs to be generated once at runtime, and from there can remain static/won't be changed again. The amount of entries is also determined during this generation, and is never changed again (no entries added or removed). However, the menu in which they reside in can be freely navigated to, making this lag spike a slight inconvenience.

    I have tried every optimization trick in the book that I know and could find - this list resides in its own canvas, all layout components are destroyed after generation, the text mesh component is as stripped down as possible, and even the auto sizing is disabled once generated. And although this all helps a lot, I am still seeing a ~120ms spike whenever this menu - along with all the text components - is enabled.

    And just in case - yes, considering all these entries are part of a scroll rect with many other moving parts, I do need to disable it when navigating elsewhere, and re-enable it when it is necessary.

    So my question is - is there anything else I can do to stomp down this issue? Any tricks or hacks that can assist in achieving a smoother transition?

    Unity Version Used: 2019.3.7f1
    TextMeshPro Version Used: 2.1.6

    Thank you kindly for your time. :)
     

    Attached Files:

    Last edited: Oct 29, 2021