0
0
Unityframework~8 mins

Text and TextMeshPro in Unity - Performance & Optimization

Choose your learning style9 modes available
Performance: Text and TextMeshPro
MEDIUM IMPACT
This concept affects how quickly text appears and updates on screen, impacting rendering speed and user interaction smoothness.
Displaying dynamic text in a Unity UI
Unity
using TMPro;

public class Example : MonoBehaviour {
    public TMP_Text tmpText;
    void Update() {
        tmpText.text = Time.time.ToString();
    }
}
TextMeshPro uses signed distance field fonts and optimized mesh generation, reducing CPU load and improving batching.
📈 Performance GainReduces mesh rebuild cost and draw calls, improving frame rate and input responsiveness.
Displaying dynamic text in a Unity UI
Unity
using UnityEngine.UI;

public class Example : MonoBehaviour {
    public Text uiText;
    void Update() {
        uiText.text = Time.time.ToString();
    }
}
The default Text component causes frequent mesh rebuilds and inefficient batching, leading to slower frame rates when text updates often.
📉 Performance CostTriggers multiple mesh rebuilds and CPU overhead every frame, increasing draw calls and reducing frame rate.
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Unity UI TextHigh mesh rebuilds on text changeMultiple reflows per updateHigher paint cost due to inefficient batching[X] Bad
TextMeshProOptimized mesh generation with cachingMinimal reflows with stable layoutLower paint cost with efficient shaders[OK] Good
Rendering Pipeline
Text rendering involves generating a mesh from font data, calculating layout, and then painting the text on screen. TextMeshPro optimizes mesh generation and uses efficient shaders.
Mesh Generation
Layout Calculation
Paint
⚠️ BottleneckMesh Generation is most expensive when text changes frequently.
Core Web Vital Affected
INP
This concept affects how quickly text appears and updates on screen, impacting rendering speed and user interaction smoothness.
Optimization Tips
1Use TextMeshPro instead of Unity UI Text for better performance and quality.
2Avoid updating text every frame unless necessary to reduce mesh rebuilds.
3Cache static text and minimize layout changes to improve rendering speed.
Performance Quiz - 3 Questions
Test your performance knowledge
Which text component in Unity generally offers better rendering performance for dynamic text?
ATextMeshPro
BUnity UI Text
CRaw Image
DSprite Renderer
DevTools: Unity Profiler
How to check: Open Unity Profiler, select Rendering and UI modules, then observe CPU usage and draw calls during text updates.
What to look for: Look for high CPU spikes and many draw calls indicating inefficient text rendering.