3D Text GameObjects
By default, a TextMesh Pro 3D Text GameObject has the following components:
- Rect Transform: Controls the GameObject's position and size. For more information, see the Rect Transform documentation in the Unity Manual.
Note
Note: If you want to use the Rect Transform component's anchoring system, the TextMesh Pro component's parent GameObject must also have a Rect Transform component.
- Mesh Renderer: Renders the GameObject. For more information, see the Mesh Renderer documentation in the Unity Manual.
- TextMesh Pro UGUI (Script): Contains the text to display, and the properties that control its appearance and behavior. These properties are described below.
- Material: A Unity material that uses one of the TextMesh Pro shaders to further control the text's appearance. For more information see the Shaders section.
Properties Overview
Text input | |
A | Text: Where you enter the text to display, along with any rich text markup. |
Main settings | |
B | Font: Specifies the font to use, as well as basic font attributes (size, style, and so on). |
C | Color: Defines the base color or color gradient for the text |
D | Spacing: Controls spacing between characters, words, lines and, paragraphs. |
E | Alignment: Controls horizontal and vertical text alignment. |
F | Wrapping and Overflow: Controls word wrapping and defines what happens when text doesn't fit inside its display area. |
G | UV Mapping: Controls how textures are mapped to the face and outline of the text. |
H | Extra Settings: Additional options for controlling the appearance and behavior of text. |
Text Input
The text section is where you enter the text to display, and optionally customize it using rich text markup.
Property: | Function: | |
---|---|---|
Text | The input field for text to display. | |
Enable RTL Editor | Enable this option to display text right-to-left instead of left-to-right. The Inspector displays an additional input field where you can view the reversed text and edit it directly. The text is reversed before it is displayed on screen or rendered. |
Main Settings
The Main Settings section contains the properties needed to define the basic appearance of text. You can further customize the look of text by changing or editing its material.
Font
The fonts settings panel is where you choose a font for your text, and customize the font style.
Property: | Function: | |
---|---|---|
Font Asset | Choose a font Asset for the TextMesh Pro GameObject to use. TextMesh Pro ships with several font assets, and you can create others from standard font files such as truetype (ttf) fonts. Note: You can set the default font Asset for new text objects in the TextMesh Pro settings. |
|
Material Preset | Choose a material for your font. Each font Asset has a default material, but you can also create customized materials for it. This preset list includes all materials whose names contain the font Asset's name, and use the corresponding font atlas texture. |
|
Font Style | Enable standard text styling options. You can use these options in any combination, except for the casing options (lowercase, uppercase, and small caps), which are mutually exclusive. |
|
B | Bold the text. The appearance of bold text is defined in the font Asset properties. |
|
I | Italicize the text. The appearance of italicized text is defined in the font Asset properties. |
|
U | Underline the text. This renders an extra line below the baseline. |
|
S | Add a strikethrough line to the text. This renders an extra line above the baseline. |
|
ab | Convert the text to lowercase before rendering. This does not change text casing in the Text field. |
|
AB | Convert the text to uppercase before rendering. This does not change text casing in the Text field. |
|
SC | Use small caps. The text is displayed in all uppercase, but letters you actually entered in uppercase are larger. |
|
Font Size | Specify the text display size, in points. | |
Auto Size | Enable this option to set the font size automatically, based on the Auto Size Options. When this option is enabled, TextMesh Pro lays out the text multiple times to find a good fit. This is a resource intensive process, so avoid auto-sizing dynamic text that changes frequently. Tip: For static text, you can enable Auto Size, note the calculated font size (displayed in the Font Size field), then disable Auto Size and apply the calculated size manually. |
|
Auto Size Options | Define the basic rules for auto-sizing text. | |
Min | Specify the smallest acceptable font size, in points. | |
Max | Specify the largest acceptable font size, in points. | |
WD% | Specify the maximum acceptable amount to reduce character width when sizing the text. TextMesh Pro squeezes characters to make them taller. This is usually only acceptable for digits. |
|
Line | Adjust the line height. This is useful for fitting a larger font into a given space. |
Color
TextMesh Pro uses vertex colors to tint the text. You can apply a uniform color as well a gradient of up to four colors.
Property: | Function: | |
---|---|---|
Vertex Color | Choose the main color for the text. Any colors and textures defined in the TextMesh Pro GameObject or its material ar multiplied with this color. |
|
Color Gradient | Enable this option to apply a color gradient to each character sprite. You can then set the gradient’s type and colors, or apply a color gradient preset. Gradient colors are multiplied with the Vertex Color. If Vertex Color is set to white you see only the gradient colors. If it’s set to black you don’t see the gradient colors at all. |
|
Color Preset | Choose a color gradient preset. When you apply a preset its Color Mode and Colors replace the text's local properties in the Inspector. Editing these properties modifies the preset, which affects every TextMesh Pro GameObject that uses it. Set this property to None to revert to the text’s local gradient properties. |
|
Color Mode | Choose the type of color gradient to apply. TextMesh Pro applies gradients to each character individually. |
|
Single | A uniform color that modifies the base Vertex Color. | |
Horizontal Gradient | A two-color gradient with each color emanating from one side of the character. | |
Vertical Gradient | A two-color gradient with one color emanating from the top of the character, and the other from the bottom. | |
Four Corners Gradient | A four-color gradient with each color emanating from a different corner of the character. | |
Colors | Choose each gradient color. The number of available colors depends on the type of gradient, and the color fields are arranged to match the position of each color in the gradient (left and right, top and bottom, 2 rows of 2 for four-corner gradients). You can set the color in any of the following ways: Swatch: Click to open a color picker. Eyedropper: Click to choose a color from any part of the screen. Hex Value: Enter the RGBA hex value directly. |
|
Override Tags | Enable this option to ignore any rich text tags that change text color. |
Spacing
These options control spacing between characters, words, lines and, paragraphs. You can use them to fine-tune the text for individual TextMesh Pro GameObjects, without adjusting their font assets.
To control spacing within a single TextMesh Pro GameObject, use rich text tags.
Property: | Function: | |
---|---|---|
Character | Set the spacing between characters for this TextMesh Pro GameObject. | |
Word | Set the spacing between words for this TextMesh Pro GameObject. | |
Line | Set the spacing between lines for this TextMesh Pro GameObject. | |
Paragraph | Set the spacing between paragraphs for this TextMesh Pro GameObject. Paragraphs are defined by explicit line breaks. |
Alignment
The horizontal and vertical alignment options control how text is placed in the display area.
Property: | Function: | |
---|---|---|
[Horizontal Alignment Options] | ||
Left, Center, Right | Position the text horizontally in the display area, without changing the text itself. | |
Justified, Flush | Stretch the text to fill the width of the display area by increasing the distance between words and characters. The Wrap Mix option controls the balance between word and character spacing. Justified mode does not stretch the last lines of paragraphs, while Flush mode does. |
|
Geometry Center | Centers the text based on the mesh rather than the text metrics. The difference is not always noticeable, but in some cases this mode yields better looking results than regular Center alignment. |
|
[Vertical Alignment Options] | ||
Top, Middle, Bottom | Position the text vertically in the display area, without changing the text itself. | |
Baseline | Position the text so the baseline of the line is aligned with the middle of the display area. This is useful when working with a single line of text. |
|
Midline | Use this as an alternative to Middle alignnment. This option determine vertical placement using the bounds of the text mesh, rather than line metrics. This is useful in tight spaces when ascenders and descenders might otherwise extend too far. |
|
Capline | Position the text so the middle of the first the line is aligned with the middle of the display area. | |
Wrap Mix (W <-> C) | Adjust the balance between extra word spacing and extra character spacing when horizontal alignment is set to Justified or Flush. |
Wrapping and Overflow
Wrapping splits lines of text to ensure that they don't get wider than the display area. Lines are normally wrapped at word boundaries, but words that are longer than an entire line are split as well. Overflow controls what happens when the text doesn't fit inside the display area.
Some overflow options supersede wrapping. For example, if Overflow is set to truncate, the text is truncated when it reaches the edge of the display area, irrespective of whether Wrapping is enabled.
Property: | Function: | |
---|---|---|
Wrapping | Enable or Disable word wrapping. | |
Overflow | Specify what happens when the text doesn't fit inside the display area. | |
Overflow | Extends the text beyond the bounds of the display area, but still wraps it if Wrapping is enabled. | |
Ellipsis | Cuts off the text and inserts an ellipsis (…) to indicate that some of the text is omitted. | |
Masking | Like Overflow, but the shader hides everything outside of the display area. | |
Truncate | Cuts off the text when it no longer fits. | |
Scroll Rect | A legacy mode that’s similar to Masking. This option is available strictly for compatibility with older TextMesh Pro projects. For new projects, use Masking mode instead. | |
Page | Cuts the text into several pages that each fit inside the display area. You can choose which page to display. You can also use rich text to manually insert page breaks. Note: The vertical alignment options work on a per-page basis. |
|
Linked | Extends the text into another TextMesh Pro GameObject that you select. This is useful for creating multi-column text. |
UV Mapping
Some TextMesh Pro shaders allow you to apply one or more image textures to text. These options control how those textures stretch to fit the text.
You can also edit shader-specific texturing options in the shaders themselves. The available options depend on the shader you use.
When texturing text, make sure that your texture assets have their Wrap Mode set to Repeat. Otherwise the texture is likely to be heavily distorted when applied to the text. See the Render Texture documentation in the Unity Manual for more information.
Property: | Function: | |
---|---|---|
Horizontal Mapping | Specify how textures map to text horizontally when you use a shader that supports textures. | |
Character | Stretches the texture horizontally across each character's sprite. | |
Line | Stretches the texture horizontally across the entire width of each line. | |
Paragraph | Stretches the texture horizontally across the entire text. | |
Match Aspect | Scales the texture horizontally so it maintains its aspect ratio, and is not deformed. When you use this horizontal mapping mode, the Vertical Mapping setting determines how the texture is mapped to the text, and must be set to something other than Match Aspect. |
|
Vertical Mapping | Specify how textures map to text vertically when you use a shader that supports textures. | |
Character | Stretches the texture vertically across each character's sprite. | |
Line | Stretches the texture vertically across the entire width of each line. | |
Paragraph | Stretches the texture vertically across the entire text. | |
Match Aspect | Scales the texture vertically so it maintains its aspect ratio, and is not deformed. When you use this vertical mapping mode, the Horizontal Mapping setting determines how the texture is mapped to the text, and must be set to something other than Match Aspect. |
|
Line Offset | When Horizontal Mapping is set to Line, Paragraph, or Match Aspect, set this value to add a horizontal texture offset to each successive line. This value is added to the Offset X value you specify in the shader. |
Extra Settings
This section contains assorted options for further controlling the appearance and behavior of text.
Property: | Function: | |
---|---|---|
Margins | Set positive values to increase the distance between the text and the boundaries of the text container. Set negative values to make the text extend beyond the boundaries of the text container. You set the Left, Top, Right, and Bottom margins separately. You can also adjust the margins by dragging the handles of the text container Widget (yellow rectangle) in the Scene view. |
|
Sorting Layer | ||
Order in Layer | ||
Geometry Sorting | Bla | |
Normal | bla | |
Reverse | bla | |
Othographic Mode | Enable this option when creating camera-aligned text with an orthographic camera. It prevents the TextMesh Pro shader from using perspective correction. |
|
Rich Text | Enable this option to turn off rich text support for the TextMesh Pro GameObject. When rich text support is disabled, tags are not parsed and are rendered as plain text. |
|
Parse Escape Characters | Enable this option to make TextMesh Pro interpret backslash-escaped characters as special characters. For example \n is interpreted as a newline, \t as a tab, and so on. Note: This applies to rendered text. In code, escaped characters are already parsed by the compiler. |
|
Visible Descender | Use this option when using a script to slowly reveal text. Enable it to reveal the text at the bottom and move up as new lines are revealed. Disable it to reveal the text from top to bottom. To set up this type of text reveal, you must also set the vertical alignment to Bottom. |
|
Sprite Asset | ||
Volumetric Setup | Enable this option to display characters to display characters using cubes instead of quads. This makes volumetric character rendering, possible. Note: The TextMeshPro shaders do not currently support volumetric character rendering. |
|
Kerning | Enable this option to toggle kerning on for this TextMesh Pro GameObject. If new objects use a font with no kerning data, enabling this setting has no effect. |
|
Extra Padding | Enable this option to add extra padding to character sprites. TextMesh Pro creates sprites to fit the visible text, but the results isn't always perfect. This setting reduces the chances that glyphs are cut off at the boundaries of their sprites. |