Hi everyone,
It took me a while but I finally figured out how to make changes on my text with GUIText and add shadows to it. I posted a post on my blog about how to get it done and would like to share with everyone here on the forum.
Hope this helps!

After toying with a few different methods of creating in-game text, I decided to use guiText for it’s simplicity and for all the GUI scripts you can use from Unity Wiki.
Unity 3D does not have a visual GUI editor at the moment, so it isn’t always obvious how to do simple things like changing the font and adjusting font size. Here’s a quick note of how to get these basics done to get you started with in-game text!
- How do I change the font size for the text for guiText objects?
Go to Project view and find the font you are using. There you can find the setting for font size in the “import setting”. If you are using Unity iPhone, right click on the font to find “import setting”. If you need multiple font sizes, you can duplicate the font and have different import setting on each.

Alternatively you can disable “Pixel Correct” on the GUIText object itself and adjust the scale. However the text might get blurry this way so I don’t recommend it.

- How do I change the color of the text for guiText objects?
You change the color of the text by changing the color of its “material”. You can find the option in the Project view with your Font.

However if you change this color here, it will apply to all the GUIText object with this font. What if you want different GUIText objects to have different colors? I created a short script that can be attached to the GUIText object to change the color at run time. You can attach this script on your GUIText objects and select the color you want in the Inspector view when you select the GUIText object.

The script is simple, see below:
//this script changes the guiText color of the object and should be attached to an guiText object
//from [url]http://www.plinan.com[/url]
var TextColor : Color = Color.white; // define the color for this guiText object
function Start () {
guiText.material.color = TextColor;
}
- How do I add an outline or shadow to my text with guiText?
This is a bit more complicated. I use two methods in the game to create shadows and both require a little bit of work.
The first method is to create a duplicate of the same guiText (with the same text but a darker color) and move it 1 pixel to the right and 1 pixel to the bottom of the original guiText object to create a shadow effect. Make sure the duplicate is behind the original object. (You can change the renderQueue (more info) of your objects to make sure the original is in front of the duplicate. ) If you want to create a border instead of a shadow around the text, use the same method, create two duplicates, and place them behind the original slightly offset to create a border.
This is what it looks like. ![]()
This is a simple solution. However it has its problems. I need a way to display moving text, and the text doesn’t look very good with this method as the two objects don’t always move at the exact same time. So I had to find another way to create shadows for the text.
Fortunately Unity Wiki provided a solution to do this with these two scripts: SaveFontTexture and TexturedFont.
The basic idea is to
- Export the Font Texture
- Edit the Texture so that it has your desired effects (outline, shadow, or any other effects) with Photoshop or Gimp
- Create a Material with the new Texture you’ve created
- Use the Material together with the TexturedFont shader on the guiText object.
Here’s the instruction from the wiki:
Again, it looks like this in my game. I applied a small shadow to the text so it’s hard to see but it looks very different from text without the shadow.
Without shadow:![]()
With shadow:![]()
It helps to make the text more readable.
By the way, if you are looking for fonts to use, I found a few at MyFont.com. They also have free fonts that can be used for commercial purposes.
I think that’s all I have to say about guiText for now. Cheers!
-Brandon Wu