- Home /
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);
}
Comment
Best Answer
Answer by CET · Aug 04, 2012 at 07:20 PM
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
}