Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Any tips to optimize TextMeshPro

Discussion in 'UGUI & TextMesh Pro' started by Balphagore, Nov 26, 2022.

  1. Balphagore

    Balphagore

    Joined:
    Jul 18, 2019
    Posts:
    87
    I have about 500 TextMeshPro labels on scene. They are all generated during the play and are not marked as static, but they are motionless and do not change anything except the text alpha. I just change it depending on the camera zoom. And it causes a serious drop in FPS. From the profiler, i thought that any change in the alpha of the text causes a complete redraw of all TextMesh. I decoupled the change rate from Update and made it 4 times per second on a timer. This noticeably raised the FPS, but a serious drop still remains. Disabling autosize also slightly improves the situation, but then I need to figure out how to calculate the font size myself.

    Are there any other options to reduce FPS loss? I cannot reduce the number of objects, they are very important.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    First, make sure the Is Scale Static enabled in the Extra Settings.

    Text Auto Size is going to be super costly. You should only have to determine the optimum point size of a single text object where that size is then set on all other text objects. See the following thread / post about this.

    Lastly, the most efficient way to change the alpha is by modifying the vertex color alpha. Take a look at the example scene "Animating Vertex Attributes" included in the TMP Examples & Extras. Using this method does not require a new text parsing and layout phase and is very efficient.
     
    Balphagore likes this.
  3. Balphagore

    Balphagore

    Joined:
    Jul 18, 2019
    Posts:
    87
    The third option solved the problem, thank you very much. I don't even have to turn off Autosize at this stage.