- Home /
Gui.Label font size
Hello all. I have a simple pong game I am working on. Currently, I have a skin that displays both scores of each player as well as a message that reads "Player X Wins!" when the variable player1Win or player2Win is set to 1; Both the score and the message are the same font size. What I would like to do is make the message smaller so it doesn't take up so much of the screen.
var theSkin : GuiSkin;
function OnGUI()
{
GUI.skin = theSkin;
GUI.Label (new Rect (Screen.width/2-150, 20, 100, 100), "" + playerScore01);
GUI.Label (new Rect (Screen.width/2+150, 20, 100, 100), "" + playerScore02);
if (player1Win == 1) {
GUI.Label (new Rect (Screen.width/2-350, 200, 300, 300), "Player 1 Wins!");
}
else if (player2Win == 1) {
GUI.Label (new Rect (Screen.width/2+100, 200, 300, 300), "Player 2 Wins!");
}
Do I need to create new skin? Or is there a way to reduce the font size for individual labels? I attempted to create a variable called fontSize and set it to 12 as a test. I then placed it right after the message but it didn't work.
GUI.Label (new Rect (Screen.width/2+100, 200, 300, 300), "Player 1 Wins!", fontSize);
Any advice?
Answer by getyour411 · Feb 08, 2014 at 06:26 PM
There's quite a few examples of this on UA; sample
http://answers.unity3d.com/questions/137143/how-to-set-the-font-size-in-guilabel.html
I must have overlooked that. Thank you. I'll check in to it right now.
Your answer