- Home /
gui text and password field
var username : String; var password : String; var table1 : boolean; var table2 : boolean; var window1 : Rect = Rect(20,20,500,500);
function Start() { table1 = true; }
function OnGUI() { if(table2 == true) { window1 = GUI.Window(0,window1,firstwindow,"LOGIN WINDOW"); } if(table1 == true) { GUI.color = Color.green; GUI.Label(Rect(Screen.width*(2/6.55),Screen.height*(1.9/6.3),Screen.width* (1/6.55),Screen.height*(.6/6.3)),"USER"); GUI.Label(Rect(Screen.width*(2/6.55),Screen.height*(2.5/6.3),Screen.width*(1/6.55),Screen.height*(.6/6.3)),"PASSWORD"); username = GUI.TextArea(Rect(Screen.width*(3/6.55),Screen.height*(1.9/6.3),Screen.width*(1.5/6.55),Screen.height*(.3/6.3)),username,15); password = GUI.PasswordField(Rect(Screen.width*(3/6.55),Screen.height*(2.5/6.3),Screen.width*(1.5/6.55),Screen.height*(.2/6.3)),password,""[0],10); if(GUI.Button(Rect(Screen.width(2.5/6.55),Screen.height*(3.5/6.3),Screen.width*(0.5/6.55),Screen.height*(.4/6.3)),"OK")) { table2 = true; table1 = false; } } }
Here my need is when user enter the USERNAME and PASSWORD and click ok button in the login window i have to display the WHAT ever user entered in in username and password field eg if user has entered username- robert and password- mathew in login window i have to display both robert and mathew like wise for all user
Answer by e-bonneville · Feb 15, 2011 at 05:58 PM
This just an example, you can modify it to fit your needs.
function OnGUI() {
GUI.Label(Rect(10, 10, 100, 20), "Username is: " + username);
GUI.Label(Rect(10, 30, 100, 20), "Password is: " + password)
}
Untested Javascript, please report any errors.
Your answer
Follow this Question
Related Questions
GUI Text field? How do I make the text so it goes on more then one line? 1 Answer
Allow only numbers in an input field 1 Answer
GUI custom textfield cursor rendering 2 Answers
Text fields where text will scale along with resolution. 1 Answer
Change the color of a label font that's using an EditorStyle.textField style? 1 Answer