The Unity UI module uses TextMesh Pro to display text (and icons in text).
In this tutorial we’ll set up TextMesh Pro (TMP for short) to use a font and sprite asset. Make sure TMP is imported in your project (e.g. via the Unity Package Manager).
Import Essential Resources #
Import the TMP essential resources via the Unity menu: Window > TextMeshPro > Import TMP Essential Resources
Depending on your Unity/TMP version this might also be located somewhere else.
Default Font and Sprites #
If you don’t already have a font and icons to use (e.g. from a tutorial asset package), you can download a font and icons here:
TMP Settings #
Both come with ready to use TMP assets, that we’ll now use as default font and sprites. Select the TMP Settings asset, which should be located in Assets/TextMesh Pro/Resources/.
Default Font Asset #
The default font will be used by newly created TMP components as their font.
- Defaul Font Asset
Select the FFFFORWA SDF font asset (or any other TMP font asset you created).
Default Sprite Asset #
- Defaul Sprite Asset
Select the icons sprite asset (or any other TMP sprite asset you created).
Creating Own Fonts and Icons #
TMP uses special font and icon assets – you can create them easily from regular fonts and sprites (usually using spritesheets) via the context menu in the project hierarchy tab.
TMP Font Asset #
To create a TMP font asset from a font in your project, right-click on the font and select: Create > TextMeshPro > Font Asset
TMP Sprite Asset #
Similar, to create a TMP sprite asset from a sprite in your project, right click on the sprite and select: Create > TextMeshPro > Sprite Asset
You might need to adjust the positioning of your sprites, this is best handled via the Sprite Glyph Table settings of the TMP sprite asset. Adjusting the OX and OY settings will change all included sprites.
When not used as default font/icons, the TMP font/sprite assets need to be placed in defined sub-folders of a Resources folder.
Those folders are defined in the TMP Settings asset and default to Fonts & Materials (for fonts) and Sprite Assets (for sprites).