Probably a really basic question - how do I change the styling of text in the GUI such as font size, colour, bold, italic? I’ve searched the documentation but can’t see the script for it anywhere.
Hello,
This is how I do mine
Asset - Crate - GUI Skin.
then on the inspector, drag your custom font.
font size can be change in the import settings.
your new GUI skin font color can be change in the inspector.
I think there’s a better way of doing it but not sure.
http://unity3d.com/support/documentation/Manual/Game%20Interface%20Elements.html
see under customization
Ray
Is there a way to change the font size other than the Import Settings? It doesn’t seem to be part of the font class. So it looks like I have to have a second copy of the font in the project with different import settings.
Hi guys, here’s what I’m trying to do: When the player’s score changes I want to animate it a little bit - change the colour, make it pop a little bit - whatever I can do using the GUI commands. So far I’m having trouble doing just a basic style change. I agree with SWGraham - surely there’s a way that doesn’t involve using multiple fonts?
no-one can help me with this? ![]()
You can change text color with GUI.color. For everything else you need a different font; Unity has no vector font support.
–Eric
Oh I gotcha. Once Unity gets a font it turns it in to a texture. Can’t change the font size when it isn’t ttf anymore.
Still, it would be a slight benefit if I didn’t have to keep multiple copies of the same font on disk. Maybe if you could make the Importer spawn multiple textures from one font.
The 3D Platformer Tutorial solves the font scaling problem by using a matrix4x4.
The code is something like:
var gameOverText : GUIStyle;
var gameOverScale = 1.5;
GUI.matrix = Matrix4x4.TRS(Vector3(0,0,0), Quaternion.identity, Vector3.one * gameOverScale);
GUI.Label(Rect((Screen.width / (2 * gameOverScale)-50), (Screen.height / (2 * gameOverScale)) - 40, 300, 100), "Game Over", gameOverText);
The Matrix4x4 is listed in the docs:
file:///Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/Matrix4x4.html
Are you confused? I am!
It seems to just remap the “grid” on the screen to a different scale (in the above code a larger one), if used as simply as the example code. I get the idea, that if you get good at it, you can shear and warp with this class as well.
It’s not having a scalable font palette, but it is clearly scriptable.
- And don’t forget to reset your Matrix if you want to display something else later in the same function, as it seems to “set” the matrix for the screen and keep it there until reset with another matrix command, like this:
GUI.matrix = Matrix4x4.TRS(Vector3(0,0,0), Quaternion.identity, Vector3.one);
I’m not completely clear about all of the code, but it works.
(a) Old thread eh?
(b) If you’re confused about the GUI Matrix stuff then take a look at the GUIUtility class as it has helper functions for just this sort of thing.
Yea. Really awesome, eh? Someone is clearly using the forum search rather than reposting an already discussed issue ![]()