unity-textmeshpro

TextMeshPro (TMPro) expert for Unity text rendering with advanced typography, performance optimization, and professional text effects. Masters font asset creation, dynamic fonts, rich text formatting, material presets, and text mesh optimization. Use PROACTIVELY for text rendering, font management, localization text, UI text performance, or text effects implementation.

8 stars

Best use case

unity-textmeshpro is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

TextMeshPro (TMPro) expert for Unity text rendering with advanced typography, performance optimization, and professional text effects. Masters font asset creation, dynamic fonts, rich text formatting, material presets, and text mesh optimization. Use PROACTIVELY for text rendering, font management, localization text, UI text performance, or text effects implementation.

Teams using unity-textmeshpro should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/unity-textmeshpro/SKILL.md --create-dirs "https://raw.githubusercontent.com/creator-hian/claude-code-plugins/main/unity-plugin/skills/unity-textmeshpro/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/unity-textmeshpro/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How unity-textmeshpro Compares

Feature / Agentunity-textmeshproStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

TextMeshPro (TMPro) expert for Unity text rendering with advanced typography, performance optimization, and professional text effects. Masters font asset creation, dynamic fonts, rich text formatting, material presets, and text mesh optimization. Use PROACTIVELY for text rendering, font management, localization text, UI text performance, or text effects implementation.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Unity TextMeshPro - Professional Text Rendering

## Overview

TextMeshPro (TMPro) is Unity's advanced text rendering solution using Signed Distance Field (SDF) technology for resolution-independent, high-quality text with minimal performance overhead.

**Foundation Required**: `unity-csharp-fundamentals` (TryGetComponent, FindAnyObjectByType), `unity-ui` (UI systems, Canvas, UGUI)

**Core Topics**:
- SDF font asset creation and configuration
- Dynamic vs static font assets
- Rich text formatting and styling
- Material presets and text effects
- Performance optimization patterns
- Localization and dynamic text handling

## Quick Start

### Basic Text Setup

```csharp
using TMPro;
using UnityEngine;

public class TextController : MonoBehaviour
{
    [SerializeField] private TMP_Text mDisplayText;

    void Start()
    {
        mDisplayText.text = "Hello, World!";
        mDisplayText.fontSize = 36;
        mDisplayText.color = Color.white;
    }
}
```

### TMP_Text vs TextMeshProUGUI vs TextMeshPro

```csharp
// TMP_Text - Base class, use for serialization (works with both)
[SerializeField] private TMP_Text mText;

// TextMeshProUGUI - Canvas UI text (most common)
[SerializeField] private TextMeshProUGUI mUiText;

// TextMeshPro - 3D world space text (MeshRenderer)
[SerializeField] private TextMeshPro mWorldText;
```

### Rich Text Formatting

```csharp
// Basic formatting
text.text = "<b>Bold</b> and <i>Italic</i>";
text.text = "<size=48>Large</size> and <size=24>Small</size>";
text.text = "<color=#FF0000>Red</color> text";

// Advanced formatting
text.text = "<mark=#FFFF00AA>Highlighted</mark>";
text.text = "H<sub>2</sub>O and E=mc<sup>2</sup>";
text.text = "<s>Strikethrough</s> and <u>Underline</u>";

// Sprite embedding
text.text = "Score: 100 <sprite=0>";
```

## Component Selection Guide

| Scenario | Component | Reason |
|----------|-----------|--------|
| UI Canvas text | TextMeshProUGUI | Canvas integration, auto-batching |
| 3D world labels | TextMeshPro | MeshRenderer, world-space |
| Serialized reference | TMP_Text | Works with both types |
| Input field | TMP_InputField | Built-in input handling |
| Dropdown | TMP_Dropdown | Built-in dropdown UI |

## Font Asset Best Practices

### Font Asset Types

```
Static Font Asset:
- Pre-generated character set
- Best performance (no runtime generation)
- Use for: Known character sets, optimized builds

Dynamic Font Asset:
- Runtime character generation
- Flexible but slower initial render
- Use for: Localization, user input, unknown characters
```

### Creating Optimal Font Assets

1. **Font Asset Creator** (Window > TextMeshPro > Font Asset Creator)
   - Set appropriate Atlas Resolution (1024x1024 for basic, 2048x2048 for CJK)
   - Use "Custom Character List" for known character sets
   - Enable Multi Atlas Textures for large character sets

2. **Sampling Point Size**: Use highest size that fits atlas (better quality)

3. **Padding**: 5-9 for normal use, higher for effects (outline, glow)

## Performance Guidelines

### Text Update Optimization

```csharp
// BAD: Frequent text changes trigger mesh rebuild
void Update()
{
    scoreText.text = $"Score: {score}"; // Rebuilds every frame
}

// GOOD: Update only when value changes
private int mLastScore = -1;

void Update()
{
    if (score != mLastScore)
    {
        mLastScore = score;
        scoreText.text = $"Score: {score}";
    }
}

// BETTER: Use SetText for formatted updates (less allocation)
void UpdateScore(int score)
{
    scoreText.SetText("Score: {0}", score);
}
```

### Memory-Efficient Patterns

```csharp
// Use StringBuilder for complex text construction
private readonly StringBuilder mSb = new StringBuilder(256);

void BuildComplexText()
{
    mSb.Clear();
    mSb.Append("Player: ");
    mSb.Append(playerName);
    mSb.Append(" | Score: ");
    mSb.Append(score);
    displayText.SetText(mSb);
}

// Prefer SetText with parameters over string interpolation
text.SetText("{0}/{1}", currentHP, maxHP);  // Less GC
// Instead of
text.text = $"{currentHP}/{maxHP}";         // More GC
```

## Material Presets

```csharp
// Apply material preset at runtime
[SerializeField] private Material mHighlightMaterial;
[SerializeField] private Material mNormalMaterial;

void Highlight(bool active)
{
    mText.fontMaterial = active ? mHighlightMaterial : mNormalMaterial;
}

// Modify material properties
mText.fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.2f);
mText.fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, Color.black);
```

## Reference Documentation

### [Fundamentals](references/fundamentals.md)
Core TextMeshPro concepts:
- SDF technology explanation
- Font asset creation workflow
- Character sets and fallback fonts
- Sprite assets integration
- Style sheets usage

### [Performance Optimization](references/performance-optimization.md)
Optimization techniques:
- Mesh geometry optimization
- Dynamic batching strategies
- Font atlas memory management
- Text update minimization patterns
- Profiling text rendering

### [Advanced Patterns](references/advanced-patterns.md)
Advanced usage patterns:
- Custom shaders and effects
- Text animation techniques
- Localization integration
- Typewriter effects
- Link and event handling

## Key Principles

1. **Use TMP_Text for References**: Base class works with both UI and 3D text
2. **Prefer SetText() over .text**: Reduces GC allocations for dynamic values
3. **Update Only When Changed**: Avoid unnecessary mesh rebuilds
4. **Choose Appropriate Font Assets**: Static for performance, Dynamic for flexibility
5. **Batch Similar Text**: Group text with same material for draw call reduction

## Common Anti-Patterns

```csharp
// AVOID: Creating new materials per text instance
text.fontMaterial = new Material(text.fontMaterial); // Memory leak risk

// AVOID: Updating text in Update() without change check
void Update() { text.text = score.ToString(); } // Constant rebuild

// AVOID: Excessive rich text nesting
text.text = "<b><i><color=#FF0000><size=48>...</size></color></i></b>";

// AVOID: Dynamic fonts for static content
// Use pre-generated static font assets instead
```

## Platform Considerations

- **Mobile**: Use static font assets, minimize atlas size, avoid complex effects
- **WebGL**: Pre-load font assets, avoid dynamic font generation
- **VR/AR**: Consider text readability, use larger fonts, avoid thin outlines

## Integration with Other Skills

- **unity-ui**: TextMeshPro integrates with Canvas and UI Toolkit
- **unity-performance**: Text rendering impacts draw calls and memory
- **unity-mobile**: Font asset optimization critical for mobile
- **unity-async**: Async font loading with Addressables

Related Skills

unity-vcontainer

8
from creator-hian/claude-code-plugins

VContainer dependency injection expert specializing in IoC container configuration, lifecycle management, and Unity-optimized DI patterns. Masters dependency resolution, scoped containers, and testable architecture design. Use PROACTIVELY for VContainer setup, service registration, or SOLID principle implementation.

unity-unitask

8
from creator-hian/claude-code-plugins

UniTask library expert specializing in allocation-free async/await patterns, coroutine migration, and Unity-optimized asynchronous programming. Masters UniTask performance optimizations, cancellation handling, and memory-efficient async operations. Use PROACTIVELY for UniTask implementation, async optimization, or coroutine replacement.

unity-unirx

8
from creator-hian/claude-code-plugins

UniRx (Reactive Extensions) library expert for legacy Unity projects. Specializes in UniRx-specific patterns, Observable streams, and ReactiveProperty. Use for maintaining existing UniRx codebases. For new projects, use unity-r3 skill instead.

unity-ui

8
from creator-hian/claude-code-plugins

Build and optimize Unity UI with UI Toolkit and UGUI. Masters responsive layouts, event systems, and performance optimization. Use for UI implementation, Canvas optimization, or cross-platform UI challenges.

unity-testrunner

8
from creator-hian/claude-code-plugins

Unity Test Framework CLI automation and test writing patterns. Masters batchmode execution, NUnit assertions, EditMode/PlayMode testing, and TDD workflows. Use PROACTIVELY for test automation, CI/CD pipelines, or test-driven development in Unity.

unity-r3

8
from creator-hian/claude-code-plugins

R3 (Reactive Extensions) library expert specializing in modern reactive programming patterns, event-driven architectures, and Observable streams. Masters R3-specific features, async enumerable integration, and Unity-optimized reactive patterns. Use PROACTIVELY for R3 implementation, reactive programming, or MVVM/MVP architecture.

unity-performance

8
from creator-hian/claude-code-plugins

Optimize Unity game performance through profiling, draw call reduction, and resource management. Masters batching, LOD, occlusion culling, and mobile optimization. Use for performance bottlenecks, frame rate issues, or optimization strategies.

unity-networking

8
from creator-hian/claude-code-plugins

Implement multiplayer games with Unity Netcode, Mirror, or Photon. Masters client-server architecture, state synchronization, and lag compensation. Use for multiplayer features, networking issues, or real-time synchronization.

unity-mobile

8
from creator-hian/claude-code-plugins

Optimize Unity games for mobile platforms with IL2CPP, platform-specific code, and memory management. Masters iOS/Android deployment, app size reduction, and battery optimization. Use for mobile builds, platform issues, or device-specific optimization.

unity-csharp-fundamentals

8
from creator-hian/claude-code-plugins

Unity C# fundamental patterns including TryGetComponent, SerializeField, RequireComponent, and safe coding practices. Essential patterns for robust Unity development. Use PROACTIVELY for any Unity C# code to ensure best practices.

unity-collection-pool

8
from creator-hian/claude-code-plugins

Unity Collection Pool expert for GC-free collection management using ListPool, DictionaryPool, HashSetPool, and ObjectPool. Masters memory optimization, pool sizing, and allocation-free patterns. Use PROACTIVELY for collection allocations, GC pressure reduction, temporary list/dictionary usage, or performance-critical code paths.

unity-async

8
from creator-hian/claude-code-plugins

Handle Unity's asynchronous programming patterns including coroutines, async/await, and Job System. Masters Unity's main thread restrictions and threading models. Use when guidance needed on Unity async operations, coroutine optimization, or parallel processing in Unity context.