User interface Unity3D gui表单文本太小
因此,对于我的代码,我让用户在提交分数之前输入他们的名字。但是,表单文本非常小。“名称”和“提交”不会更改。我可以在用户输入姓名的文本字段中更改文本 谢谢你的见解User interface Unity3D gui表单文本太小,user-interface,unity3d,textfield,unityscript,User Interface,Unity3d,Textfield,Unityscript,因此,对于我的代码,我让用户在提交分数之前输入他们的名字。但是,表单文本非常小。“名称”和“提交”不会更改。我可以在用户输入姓名的文本字段中更改文本 谢谢你的见解 private var formNick = ""; var pointObject : Transform; private var formScore = ""; var bigFont: GUIStyle; var formText = ""; var URL = " "; function OnGUI() { GU
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");
}
您可以使用GUI样式更改字体大小
function OnGUI() {
var style : GUIStyle = new GUIStyle();
style.fontSize = 25;
GUI.Label( Rect ( Screen.width/2 - 20, Screen.height/2, 80, 20), "Name:", style);
}