OnGUI不会出现

时间:2015-11-08 00:18:45

标签: c# unity3d

当我出于某种原因开始游戏时,OnGui不会出现。我已将脚本附加到游戏对象:

public class username : MonoBehaviour {

private static string user = "";

void OnGui()
{

    GUI.Label(new Rect((Screen.width / 2), (Screen.height / 2), 300, 300), "Username");
    user = GUI.TextField(new Rect(-4, 0, 100, 100), user);

    if (GUI.Button(new Rect(-4, 0, 200, 30), "Continue"))
    {
        WWWForm form = new WWWForm();
        form.AddField("", user);
        WWW w = new WWW("http://site/register.php", form);
        StartCoroutine(register(w));
    }

}

由于

1 个答案:

答案 0 :(得分:5)

OnGui()区分大小写,需要是OnGUI()。

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnGUI.html