PasswordField

From Unify Community Wiki
Revision as of 12:16, 29 October 2007 by Opless (Talk | contribs)

Jump to: navigation, search

by Shaun le Lacheur and StarManta

Usage

Insert the function into any .js file. You can then call this as you would call GUILayout.Textfield. TODO: allow for input of GUIStyles. For now, just hardcode them into the TextFeld call in the function.


<javascript> static function PasswordField(password : String, maskChar : String) : String { if (Event.current.type == EventType.repaint || Event.current.type == EventType.mouseDown) { strPasswordMask = ""; for (i = 0; i <password.Length; i++) { strPasswordMask += maskChar; } } else { strPasswordMask = password; } GUI.changed = false; strPasswordMask = GUILayout.TextField(strPasswordMask, GUILayout.Width(150)); if (GUI.changed) { password = strPasswordMask; } return password; } </javascript>

C# Equivalent by Opless

<csharp> string PasswordField(string password , string maskChar) { string strPasswordMask=""; if (Event.current.type == EventType.repaint || Event.current.type == EventType.mouseDown) { strPasswordMask = ""; for (int i = 0; i <password.Length; i++) { strPasswordMask += maskChar; } } else { strPasswordMask = password; } GUI.changed = false; strPasswordMask = GUILayout.TextField(strPasswordMask, GUILayout.Width(150)); if (GUI.changed) { password = strPasswordMask; } return password; } </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox