You can use GUIStyle to change the font size.
function OnGUI() {
var style : GUIStyle = new GUIStyle();
style.fontSize = 25;
GUI.Label( Rect ( Screen.width/2 - 20, Screen.height/2, 80, 20), "Name:", style);
}
Domanda
so for my code I am having the user type in their name before they submit their score. However, the form text is really small. The "name" and "submit" won't change. I can change the text inside the textfield where users enter their name though.
Thank you for any insight.
private var formNick = "";
var pointObject : Transform;
private var formScore = "";
var bigFont: GUIStyle;
var formText = "";
var URL = " ";
function OnGUI() {
GUI.Label( Rect ( Screen.width/2 - 20, Screen.height/2, 80, 20), "Name:" );
formNick = GUI.TextField ( Rect (Screen.width/2 - 50, Screen.height/2 + 30, 100, 20), formNick,50, bigFont ); //here you will insert the new value to variable formNick
if ( GUI.Button ( Rect (Screen.width/2 - 50, Screen.height/2 + 50, 100, 20) , "Submit Score" ) ){ //just a button
if(formNick != "")
{
Submit();
enabled = false;
//Testing
}
else
{
Debug.Log("Please enter a name");
}
}
}
function Submit()
{
var form = new WWWForm();
formScore = pointObject.GetComponent(pointManager).points.ToString();
form.AddField( "name", formNick );
form.AddField( "score", formScore );
var w = WWW(URL, form);
yield w;
if (w.error != null ) {
print(w.error);
} else {
print("Score Submitted" + formScore);
}
formNick = "";
formScore = "";
Application.LoadLevel("scoreboard");
}
Soluzione
You can use GUIStyle to change the font size.
function OnGUI() {
var style : GUIStyle = new GUIStyle();
style.fontSize = 25;
GUI.Label( Rect ( Screen.width/2 - 20, Screen.height/2, 80, 20), "Name:", style);
}