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.

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:
    69
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,581
    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:
    69
    The third option solved the problem, thank you very much. I don't even have to turn off Autosize at this stage.