Time for action – creating a custom font with a text shader
You've already displayed text in your prototypes, but up until this point, we've been using the standard Arial
font. However, you can display text in any Unity-compatible font using a Text Shader
; the steps are as follows:
Create a new material and select Text Shader from the GUI list in the Shader drop-down menu.
A custom material with a
Text Shader
material attached to it has an area where you can input a texture in the Inspector window, as shown in the following screenshot:Add this texture to your asset list by importing a font file into your project and using the resulting font texture.
Next, link the
Text Shader
material to aGUI Text
object and make sure that it is displayed properly on the screen.
If you've configured the material and shader properly, you should be able to change the color of the displayed text in real time by changing the Text Color property of the material you created.
The following example shows a GUI Text...