unity3D——登录界面
效果图:
代码如下:
//用户名 private var editUsername : String; //密码 private var editPassword : String; //提示信息 private var editShow : String; function Start() { editShow = "请您输入正确的用户名与密码"; editUsername = "请输入用户名"; editPassword = "请输入密码"; } function OnGUI () { //显示提示信息内容 GUI.Label(Rect(10, 10, Screen.width, 30), editShow); if (GUI.Button(Rect(10,120,100,50),"登录")) { //点击按钮修改提示信息 editShow = "您输入的用户名为 :" + editUsername + " 您输入的密码为:"+ editPassword; } //编辑框提示信息 GUI.Label(Rect(10, 40, 50, 30), "用户名"); GUI.Label(Rect(10, 80, 50, 30), "密码:"); //获取输入框输入的内容 editUsername = GUI.TextField (Rect (60, 40, 200, 30), editUsername, 15); editPassword = GUI.PasswordField (Rect (60, 80, 200, 30), editPassword, "*"[0],15); }