x


GUI font size?

How do I change the size of my font when writing a GUI script? I already have this but I don't know how to change the size, can someone help me out?

var fullClip : int = 8;

var bulletsLeft : int = 8;

var reloadTime = 1.5;

function Update () {

if(Input.GetButtonDown("Fire1")){

    if(bulletsLeft > 0 ){

        bulletsLeft -- ;

        }

}



if(Input.GetButtonDown("r")){

    Reload();



}

}

function Reload () {

yield WaitForSeconds(reloadTime);

    bulletsLeft = fullClip ;

}

function OnGUI() {

GUI.Label (Rect (20, 300, 100, 20), ""+bulletsLeft);

}

more ▼

asked Aug 04 '12 at 05:48 PM

Blink gravatar image

Blink
106 10 22 32

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

1 answer: sort voted first

sure.

var someInt : int = 20;

OnGUI() {
     ...
     GUI.skin.label.fonSize = someInt;
     ...
}

you may also need to set the font you want to the GUI's you're using.

so to do that,

var font : Font;
var fontSize  : int = 20;

function OnGUI() {
     GUI.skin.label.font = GUI.skin.button.font = GUI.skin.box.font = font;
     GUI.skin.label.fontSize = GUI.skin.box.fontSize = GUI.skin.button.fontSize = fontSize;


     //Code for GUI stuff goes in here
}
more ▼

answered Aug 04 '12 at 07:20 PM

CET gravatar image

CET
126 1 2

(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:

x5270
x3811
x295
x250
x109

asked: Aug 04 '12 at 05:48 PM

Seen: 4645 times

Last Updated: Aug 06 '12 at 01:28 PM