VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/text-textmeshpro-in-unity/

⇱ Text (TextMeshPro) In Unity - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Text (TextMeshPro) In Unity

Last Updated : 4 May, 2026

Text is essential for any game for showing score, health, timer or menu options. Unity offers two text systems: legacy Text (UI) and TextMeshPro (TMP). TextMeshPro is the modern, recommended option with better quality and more features.

TextMeshPro

TextMeshPro is Unity's advanced text rendering system. It provides sharper text, better spacing, and more styling options than the old Unity Text.

  • Crisp text at any size or resolution.
  • Rich styling options (bold, italic, color, size).
  • Support for custom fonts and icons.
  • Better performance than legacy text.

Creating a TextMeshPro Element

Method 1: Right-click in Hierarchy - UI - Text - TextMeshPro.

Method 2: If you see "Import TMP Essentials" popup – click Import. This happens the first time you use TextMeshPro.

👁 TextMeshPro-In-Unity
TextMeshPro In Unity

Text Component Inspector

When you select a Text element, the Inspector shows these key properties:

  • Text Input: What the text says (example: "Score: 0").
  • Font Asset: Which font to use.
  • Font Size: How big or small.
  • Color: Text color.
  • Alignment: Left, center, right, top, middle, bottom.
  • Wrapping: Auto wrap to next line or not.
👁 Text-Component-Inspector-In-Unity
Text Component Inspector In Unity

Changing Text from Script

To update text during gameplay (score, timer, health), use a script.

TextMeshProUGUI is the component type for UI text. Change the .text property to update what the player sees.

Rich Text Tags

You can style specific parts of text using tags (like HTML).

Common tags:

  • <b>bold</b>: Makes text bold
  • <i>italic</i>: Makes text italic
  • <color=red>red</color>: Changes color
  • <size=150%>big</size>: Changes size
  • <br>: Line break

Font Assets

Fonts control how text looks. TextMeshPro uses .ttf or .otf font files.

To change font:

  1. Download a .ttf font file.
  2. Drag into Project window.
  3. Right-click font - Create - TextMeshPro - Font Asset.
  4. Drag new Font Asset into Text component's Font Asset slot.

Common Text Use Cases

Score Display

Health Text

Timer

Comment
Article Tags:
Article Tags:

Explore