Thursday 4 May 2017

Unity and TextMeshPro

I guess, since Unity "bought up" TextMeshPro and made it available for free with version 5.5 of Unity back in February, I'm probably one of the last to jump on board and give it a go.

Between messing about with Arduino, guitars and hall sensors, I've been playing about with Unity a bit too. I tried getting away from the whole "create the next awesome 3d blockbuster" and am looking to create simple, mobile-friendly games that should provide 10-30 minutes playtime. A bit like the old ZX Spectrum games of yesteryear (though I shudder to think how many hours I spent trying to get Mr Head and Mr Heels to work together properly in 1986).

Anyway, a simple 2D turn-based strategy game is currently in development (although it'll probably never be anything more than a vehicle for trying out different coding techniques,so don't expect a release date any time soon) and - like most game framework prototypes - is filled with coder art, empty graphics placeholders and lots of console debug messages.

As anyone who has worked with Steve will know, it's the graphics and look-and-feel that can elevate something pretty mediocre into something amazing. And that's what happened last night, when I swapped out my simple Unity GUI Text for some TextMeshPro glyphs.

Here's an example. It's dynamic text.
At certain points in the turn-based game, your turn can be interrupted by your opponent (a classic example of this is when a player leaves a character on "overwatch" - meaning "if anything crosses your field of view, shoot at it immediately").

Whenever a player is interrupted, we wanted a nice big on-screen display to inform them of what was going on. A simple 72-point dynamic text box just didn't seem to cut it. But swap out the text object for a TextMeshPro mesh and suddenly things look a lot prettier, very quickly


Just simple stuff like putting a gradient on some text can make it look so much better than a simple flat font. And TextMeshPro lets you define up to four gradient points (to get that shiny metallic look on each letter if you like).

Also, when you scale a text object up in Unity (for example, to create a "bounce-up" effect) even TTF fonts become pixellated at larger sizes. No such problem with TextMeshPro!

It's such a massive improvement on the original UI Text, it's no wonder Unity bought it up and now offer it for free as a Unity Essential. It's a great asset and a quick and simple way of making even boring stuff look pretty onscreen!

No comments:

Post a Comment