x


How to set the font size in GUI.Label

Hey guys,

I was just wondering, I have created a GUI Label, but I was wondering, how do you change the font size????

Here is my code:

var font : Font;

function OnGUI () {
GUI.skin.label.font = font;
GUI.Label (Rect (650, 650, 300, 50), "MY TEXT");
}

Thanks

-Grady

more ▼

asked Jun 29 '11 at 06:07 AM

Grady gravatar image

Grady
1.1k 66 70 82

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Pass a GUIStyle into the function and set the font size inside the GUIStyle.

http://unity3d.com/support/documentation/ScriptReference/GUIStyle.html

so your new code would be

var style : GUIStyle;
function OnGUI()
{
    GUI.Label(Rect(650, 650, 300, 50), "HELLO WORLD", style);
}

The 3d platformer tutorial has a section on GUIStyles at page 58

http://unity3d.com/support/resources/tutorials/3d-platform-game

more ▼

answered Jun 29 '11 at 06:14 AM

SilverTabby gravatar image

SilverTabby
1.9k 3 6 18

thanks so much!!!!!!!

Jun 29 '11 at 06:21 AM Grady
(comments are locked)
10|3000 characters needed characters left

Does this not work for Android?

more ▼

answered Oct 24 '12 at 07:49 PM

johnnieZombie gravatar image

johnnieZombie
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3698
x380
x286
x241
x157

asked: Jun 29 '11 at 06:07 AM

Seen: 8789 times

Last Updated: Oct 24 '12 at 07:49 PM