Performance: Text and TextMeshPro
MEDIUM IMPACT
This concept affects how quickly text appears and updates on screen, impacting rendering speed and user interaction smoothness.
using TMPro;
public class Example : MonoBehaviour {
public TMP_Text tmpText;
void Update() {
tmpText.text = Time.time.ToString();
}
}using UnityEngine.UI;
public class Example : MonoBehaviour {
public Text uiText;
void Update() {
uiText.text = Time.time.ToString();
}
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unity UI Text | High mesh rebuilds on text change | Multiple reflows per update | Higher paint cost due to inefficient batching | [X] Bad |
| TextMeshPro | Optimized mesh generation with caching | Minimal reflows with stable layout | Lower paint cost with efficient shaders | [OK] Good |