Skip to main content

TMP Text

TMP_Text is the base class of two TextMesh Pro components:

  • TextMeshProUGUI allows you to display text with a canvas renderer.
    • This component is an ideal replacement for the UI.Text component.
    • Change the "Render Mode" of your canvas depending on how you want to display your text.
      • "World Space" allows you to place text anywhere in your world.
      • "Screen Space" allows you to display text directly on the user's screen.
  • TextMeshPro allows you to display text with a mesh renderer.
    • This component does not require a canvas. It's an ideal replacement for the legacy TextMesh components.

Properties

Use the TMP_Text base class to access these properties. Both TextMeshProUGUI and TextMeshPro inherit from TMP_Text.

PropertyTypeResult
textStringAccesses the text.
isRightToLeftTextBoolGets/sets if the text needs to be displayed right to left. Useful when implementing a variety of languages.
fontMaterialMaterialGets/sets the font material. Take note that accessing this field will clone the material.
fontSharedMaterialMaterialGets/sets the shared font material. This returns null if this component's FontAsset is null.
colorColorGets/sets the color of the text.
alphaFloatGets/sets the opacity of the text.
fontSizeFloatGets/sets the size of the text.
enableAutoSizingBoolGets/sets if the text should try to size itself as big as possible and still be visible within the range of FontSizeMin and FontSizeMax.
fontSizeMinFloatThe minimum font size if AutoSizing is enabled.
fontSizeMaxFloatThe maximum font size if AutoSizing is enabled.
horizontalAlignmentHorizontalAlignmentOptionsHow the text will be aligned horizontally.
verticalAlignmentVerticalAlignmentOptionsHow the text will be aligned vertically.
alignmentTextAlignmentOptionsHow the text will be aligned overall.
characterSpacingFloatThe amount of space between characters.
wordSpacingFloatThe amount of space between words.
lineSpacingFloatThe amount of vertical space between text lines.
paragraphSpacingFloatThe amount of vertical space between paragraphs.
characterWidthAdjustmentFloatThe amount of overlap characters have.
enableWordWrappingBoolControls whether words that exceed the available space will be put on a new line.
overflowModeTextOverflowModesControls how the text will be treated if it overflows its available space.
richTextBoolGets/sets if Rich Text is enabled.
parseCtrlCharactersBoolEnables or Disables parsing of escape characters typed into input text fields, such as \n, \r, \t, or \\.
firstVisibleCharacterIntThe first character that should be made visible in conjunction with the Text Overflow Linked mode.
maxVisibleCharactersIntControls how many characters are visible from the input.
maxVisibleWordsIntControls how many words are visible from the input.
maxVisibleLinesIntControls how many lines of text are displayed.
enableboolEnables/disables the attached component.