0
我想在统一的Javascript中做一个简单的登录GUI。我目前得到了下面的代码一个简单的GUI,但我一直在尝试了一段时间做一些额外的事情:图形用户界面快速修复
- 让密码字段显示为星号(*)当东西在里面键入。
- 将登录窗口从'GUILayout.Window'更改为'GUILayout.Box',我试图从窗口框中删除标题栏,所以我试图将其更改为框但它不起作用当我改变其他变量。
- 在底部更改3个按钮的宽度,使它们的宽度相同的字段(80)对准到框右侧(下面的字段)
感谢您的帮助:d
#pragma strict
var newSkin : GUISkin;
var logoTexture : Texture2D;
var aTexture : Texture;
private var username : String = ""; // String content would be shown as placeholder text
private var password : String = ""; // String content would be shown as placeholder text
private var submitted : boolean = false;
private var windowRect0 : Rect;
function Start()
{
}
function OnGUI() // Load GUI skin GUI.skin = newSkin;
{
var screenWidth = Screen.width;
var screenHeight = Screen.height;
var windowWidth = 300;
var windowHeight = 180;
var windowX = (50);
var windowY = (50);
GUI.Box(Rect(0, 0, Screen.width, Screen.height), ""); // Box around the menu to display the background image
// Postion the login window
windowRect0 = Rect(windowX, windowY, windowWidth, windowHeight);
// Display the login window for the user form below
GUILayout.Window(0, windowRect0, UserForm, "");
}
function UserForm()
{
GUILayout.BeginVertical();
// Username Field
GUILayout.BeginHorizontal();
GUILayout.Label("Username ", GUILayout.Width(80));
username = GUILayout.TextField(username);
GUILayout.EndHorizontal();
// Password Field
GUILayout.BeginHorizontal();
GUILayout.Label("Password ", GUILayout.Width(80));
password = GUILayout.TextField(password);
GUILayout.EndHorizontal();
if (GUILayout.Button("Login")) // Login button
{
submitted = true;
}
if (GUILayout.Button("Reset Password")) // Reset password
{
username = "Username ";
password = "Password ";
submitted = false;
}
if (GUILayout.Button("Support")) // Support button
{
// Enter action here when the "Support" button is pressed
}
if (submitted)
{
GUILayout.Label("Submitted!");
}
GUILayout.EndVertical();
}