Reputation: 27041
I'm using this code below to add a Retry
and Quit
button to the GameOver
screen for my android game.
//if retry button is pressed load scene 0 the game
if(GUI.Button(new Rect(Screen.width/2-50,Screen.height/2 +100,200,140),"Retry?")){
Application.LoadLevel(0);
}
//and quit button
if(GUI.Button(new Rect(Screen.width/2-50,Screen.height/2 +200,200,140),"Quit")){
Application.Quit();
}
But the fontSize of the Gui text is so small and no matter what I try then I cant make it bigger. What can I do to solve this.
Upvotes: 1
Views: 2255
Reputation: 3615
Use style object for this.
GUIStyle style = new GUIStyle();
style.fontSize = 20;
if(GUI.Button(new Rect(Screen.width/2-50,Screen.height/2 +100,200,140),"Retry?", style)){
Application.LoadLevel(0);
}
//and quit button
if(GUI.Button(new Rect(Screen.width/2-50,Screen.height/2 +200,200,140),"Quit", style)){
Application.Quit();
}
But it is going to overwrite the original style so you probably want to make some other changes too. For example put these lines after declaration of ´style´ and before the first use of it:
style.alignment = TextAnchor.MiddleCenter;
RectOffset margin = new RectOffset();
margin.bottom = 10;
margin.top = 10;
style.margin = margin;
style.normal.background = new Texture2D(1, 1);
For all possible settings check unity's manuals.
Upvotes: 2