所以对于我的代码,我有用户类型在他们的名字之前,他们提交他们的分数。但是,表单文本非常小。"name"one_answers"submit"不会改变。我可以改变用户输入他们的名字的文本框中的文本。
谢谢你的建议。
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");
}
您可以使用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);
}