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.

Bug TMPro rendering issue caused by parent scale animation

Discussion in 'UGUI & TextMesh Pro' started by Kazeon, Sep 26, 2020.

  1. Kazeon


    May 22, 2017
    Bug reproduction steps:
    1. Create an empty object (UI) as parent
    2. Create some text mesh pro UGUI as childs of that object
    3. Add an animation to the parent object which animates it's scaling (x, y, & z), like shrinking/expanding animation
    4. Close/hide the "Scene" tab (important) then play the game & animation

    All the child tmp objects will be rendered as blocks

    Reproduction rate: 100%

    Unity version: 2019.2.6f1
    TextMeshPro version: 2.0.1

    Side Note:

    - The objects will be rendered normally only if the scene tab is open/active, which means it won't get fixed on production (build)
    - The objects will be refreshed properly when changing resolution or any property of each TMpro objects
    Last edited: Sep 26, 2020
  2. Kazeon


    May 22, 2017
    The forum doesn't allow me to edit my main post so here is my temporary fix for the issue:

    Create a script for the parent object that will populate all children TMP objects, and then call ForceMeshUpdate on each child on every frame Update, only when the parent animation is playing.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TMPro;
    6. public class ForceUpdateTMP : MonoBehaviour
    7. {
    8.     public List<TextMeshProUGUI> texts;
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         texts.AddRange(GetComponentsInChildren<TextMeshProUGUI>(true));
    14.     }
    16.     // Update is called once per frame
    17.     void Update()
    18.     {
    19.         for (int i = 0; i < texts.Count; i++)
    20.             texts[i].ForceMeshUpdate();
    21.     }
    22. }
    I do hope there's more elegant and efficient solution to this, and the bug fix.