PasswordField
Make a text field where the user can enter a password.
Read time 2 minutesLast updated 12 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.IMGUIModule
PasswordField(string, char, GUILayoutOption[])
Make a text field where the user can enter a password.
public static string PasswordField(string password, char maskChar, params GUILayoutOption[] options)
Parameters
Password to edit. The return value of this function should be assigned back to the string as shown in the example.
Character to mask the password with.
Returns
Type | Description |
|---|---|
| string | The edited password. |
Remarks

Password field in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ string passwordToEdit = "My Password"; void OnGUI() { // Make a password field that modifies passwordToEdit. passwordToEdit = GUILayout.PasswordField(passwordToEdit, "*"[0], 25); }}
PasswordField(string, char, int, GUILayoutOption[])
Make a text field where the user can enter a password.
public static string PasswordField(string password, char maskChar, int maxLength, params GUILayoutOption[] options)
Parameters
Password to edit. The return value of this function should be assigned back to the string as shown in the example.
Character to mask the password with.
The maximum length of the string. If left out, the user can type for ever and ever.
Returns
Type | Description |
|---|---|
| string | The edited password. |
Remarks

Password field in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ string passwordToEdit = "My Password"; void OnGUI() { // Make a password field that modifies passwordToEdit. passwordToEdit = GUILayout.PasswordField(passwordToEdit, "*"[0], 25); }}
PasswordField(string, char, GUIStyle, GUILayoutOption[])
Make a text field where the user can enter a password.
public static string PasswordField(string password, char maskChar, GUIStyle style, params GUILayoutOption[] options)
Parameters
Password to edit. The return value of this function should be assigned back to the string as shown in the example.
Character to mask the password with.
Returns
Type | Description |
|---|---|
| string | The edited password. |
Remarks

Password field in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ string passwordToEdit = "My Password"; void OnGUI() { // Make a password field that modifies passwordToEdit. passwordToEdit = GUILayout.PasswordField(passwordToEdit, "*"[0], 25); }}
PasswordField(string, char, int, GUIStyle, GUILayoutOption[])
Make a text field where the user can enter a password.
public static string PasswordField(string password, char maskChar, int maxLength, GUIStyle style, params GUILayoutOption[] options)
Parameters
Password to edit. The return value of this function should be assigned back to the string as shown in the example.
Character to mask the password with.
The maximum length of the string. If left out, the user can type for ever and ever.
Returns
Type | Description |
|---|---|
| string | The edited password. |
Remarks

Password field in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ string passwordToEdit = "My Password"; void OnGUI() { // Make a password field that modifies passwordToEdit. passwordToEdit = GUILayout.PasswordField(passwordToEdit, "*"[0], 25); }}