Unity3D gui表单文本太小

时间:2014-05-10 18:28:52

标签: user-interface unity3d textfield unityscript

所以对于我的代码,我在用户输入他们的分数之前输入了他们的名字。但是,表单文本非常小。 “名称”和“提交”不会改变。我可以更改用户输入其姓名的文本区域内的文本。

感谢您的任何见解。

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");

}

1 个答案:

答案 0 :(得分:0)

您可以使用GUIStyle更改字体大小。

function OnGUI() {
    var style : GUIStyle = new GUIStyle();
    style.fontSize = 25;
    GUI.Label( Rect ( Screen.width/2 - 20, Screen.height/2, 80, 20), "Name:", style); 
}