GUI Font Size change

Hi, How to change font size in function OnGUI ?
I have script something like this :

function OnGUI(){
GUI.Box(Rect(20,20,Screen.width - 40,Screen.height - 40),"Main Menu");
}

Can you tell me how to do this ? :slight_smile:

You use a GUIStyle. There is another box function which takes the GUIStyle as an argument after the text.
static function Box (position : Rect, text : String, style : GUIStyle) : void
You name the GUIStyle at the head of your script, then go to the editor and set the font size, and add the name in the box constructor.

What about font color?

var GuiStyle : GUIStyle;

function OnGUI(){

	GUI.Box( Rect(20, 20, Screen.width - 40, Screen.height - 40), "Main Menu", GuiStyle);

}

Now the object has a GUIStyle, and in the inspector you can chance font size and color, and many other things.

If you don’t wanna make a GUI skin,You can use the following lines:

//Change Font Size
GUI.skin.box.fontSize=50;
GUI.skin.box.wordWrap=false;

//Change Font Color
GUI.skin.box.normal.textColor=Color.red;

Hope it helps.