# PasswordField

> Make a text field where the user can enter a password.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.IMGUIModule

## PasswordField(string, char, GUILayoutOption\[])

Make a text field where the user can enter a password.

```csharp
public static string PasswordField(string password, char maskChar, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Password to edit. The return value of this function should be assigned back to the string as shown in the example.**** (\[char]\(https\://learn.microsoft.com/dotnet/api/system.char)): Character to mask the password with.**** (\[GUILayoutOption\[]]\(/engine/6000.0/script-reference/unityengine/guilayoutoption)):&#x20;

### Returns

| Type                                                           | Description          |
| -------------------------------------------------------------- | -------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | The edited password. |

### Remarks

![GUILayoutPasswordField (PasswordField)](/api/media?file=/engine/6000.0/media/images/GUILayoutPasswordField.png)

*Password field in the Game View.*

### Examples

```csharp
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.

```csharp
public static string PasswordField(string password, char maskChar, int maxLength, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Password to edit. The return value of this function should be assigned back to the string as shown in the example.**** (\[char]\(https\://learn.microsoft.com/dotnet/api/system.char)): Character to mask the password with.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The maximum length of the string. If left out, the user can type for ever and ever.**** (\[GUILayoutOption\[]]\(/engine/6000.0/script-reference/unityengine/guilayoutoption)):&#x20;

### Returns

| Type                                                           | Description          |
| -------------------------------------------------------------- | -------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | The edited password. |

### Remarks

![GUILayoutPasswordField (PasswordField)](/api/media?file=/engine/6000.0/media/images/GUILayoutPasswordField.png)

*Password field in the Game View.*

### Examples

```csharp
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.

```csharp
public static string PasswordField(string password, char maskChar, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Password to edit. The return value of this function should be assigned back to the string as shown in the example.**** (\[char]\(https\://learn.microsoft.com/dotnet/api/system.char)): Character to mask the password with.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): The style to use. If left out, the textField style from the current [GUISkin](/engine/6000.0/script-reference/unityengine/guiskin.md) is used.**** (\[GUILayoutOption\[]]\(/engine/6000.0/script-reference/unityengine/guilayoutoption)):&#x20;

### Returns

| Type                                                           | Description          |
| -------------------------------------------------------------- | -------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | The edited password. |

### Remarks

![GUILayoutPasswordField (PasswordField)](/api/media?file=/engine/6000.0/media/images/GUILayoutPasswordField.png)

*Password field in the Game View.*

### Examples

```csharp
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.

```csharp
public static string PasswordField(string password, char maskChar, int maxLength, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Password to edit. The return value of this function should be assigned back to the string as shown in the example.**** (\[char]\(https\://learn.microsoft.com/dotnet/api/system.char)): Character to mask the password with.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The maximum length of the string. If left out, the user can type for ever and ever.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): The style to use. If left out, the textField style from the current [GUISkin](/engine/6000.0/script-reference/unityengine/guiskin.md) is used.**** (\[GUILayoutOption\[]]\(/engine/6000.0/script-reference/unityengine/guilayoutoption)):&#x20;

### Returns

| Type                                                           | Description          |
| -------------------------------------------------------------- | -------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | The edited password. |

### Remarks

![GUILayoutPasswordField (PasswordField)](/api/media?file=/engine/6000.0/media/images/GUILayoutPasswordField.png)

*Password field in the Game View.*

### Examples

```csharp
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);
    }
}
```
