Unity UI System: TextMeshPro and Font Asset Creation

Gerald Clark
3 min readJan 11, 2024

If you’re not using Text Mesh Pro… c’mon man… it’s the GOAT for sure. Nothing against the basic text UI, but TextMeshPro just has so much more to offer.

To make text in Unity, simply right click in your hierarchy, navigate to UI > Text — TextMeshPro.

Yay text is here. As you can see, even text has a rect transform. This is handy for centering or aligning your text to the left or right. It gives you a reference point.

So lets say we want to display a dialogue. I wont be going into how to create a dialogue system in this article. Just going to touch on a few things that will make it a little easier for you if you decide to do it. :)

This was created with a simple text mesh pro element and two images. Here is the set up in Unity:

I have the canvas, the background image, the panel that I’ve sized to be a rectangle at the bottom of the screen, and the text and icon I’ve nested within that.

I did that to make sizing the text and icon easier. Instead of dealing with weird numbers I can just make the text stretch on all four corners and give the text a sligt offset to fit the icon in.

The text looks kinda boring though. This is where font assets come in handy.

With TextMeshPro, you can import a TTF (true type font) file, create a text atlas and then have that converted into a font asset that you can use for the text. urbanfonts.com is a decent website for free fonts.

I’ve imported a random font I downloaded. Now I’ll make a text asset.

To do this, go to Window at the top of the screen, navigate to TextMeshPro > Font Asset Creator.

This window should pop up. Simply drag your TTF file into the source field. I like to change the character set to ASCII Extended to make sure symbols like question marks, commas, apostrophes, etc actually show up… if that TTF file has them.

Then click generate font atlas. Save it. Now you have a font asset!

Now all you have to do is drag that into the font asset field of the text mesh pro text component.

Instantly cooler! There are lots of other parameters you can change such as the text size, color, spacing options, etc. I encourage you to play aorund with it.

Playing aorund with the extra settings for 30 seconds created this! Weird, glowy, 3D-ish, words! Surely spending some time with this and customizing each character’s text to look different will take your game’s dialogue to the next level!

--

--

Gerald Clark

Father Game Developer Music Composer Sound Designer