# PasswordField

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

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## PasswordField(string, GUILayoutOption\[])

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

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The password to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

This works just like [GUILayout.PasswordField](/engine/6000.7/script-reference/unityengine/guilayout/passwordfield.md), but correctly responds to select all, etc. in the editor, and it can have an optional label in front.

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

*Simple window that visualizes what you have typed in the password field.*

### Examples

```csharp
// Editor Script that creates a password field and lets you
// visualize what have you typed in a label.

using UnityEditor;
using UnityEngine;

public class ExampleClass : EditorWindow
{
    string text  = "Some text here";

    [MenuItem("Examples/Editor Password field usage")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        text = EditorGUILayout.PasswordField("Type Something:", text);
        EditorGUILayout.LabelField("Written Text:", text);
    }
}
```

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

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

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The password to edit.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

This works just like [GUILayout.PasswordField](/engine/6000.7/script-reference/unityengine/guilayout/passwordfield.md), but correctly responds to select all, etc. in the editor, and it can have an optional label in front.

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

*Simple window that visualizes what you have typed in the password field.*

### Examples

```csharp
// Editor Script that creates a password field and lets you
// visualize what have you typed in a label.

using UnityEditor;
using UnityEngine;

public class ExampleClass : EditorWindow
{
    string text  = "Some text here";

    [MenuItem("Examples/Editor Password field usage")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        text = EditorGUILayout.PasswordField("Type Something:", text);
        EditorGUILayout.LabelField("Written Text:", text);
    }
}
```

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

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

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the password field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The password to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

This works just like [GUILayout.PasswordField](/engine/6000.7/script-reference/unityengine/guilayout/passwordfield.md), but correctly responds to select all, etc. in the editor, and it can have an optional label in front.

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

*Simple window that visualizes what you have typed in the password field.*

### Examples

```csharp
// Editor Script that creates a password field and lets you
// visualize what have you typed in a label.

using UnityEditor;
using UnityEngine;

public class ExampleClass : EditorWindow
{
    string text  = "Some text here";

    [MenuItem("Examples/Editor Password field usage")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        text = EditorGUILayout.PasswordField("Type Something:", text);
        EditorGUILayout.LabelField("Written Text:", text);
    }
}
```

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

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

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the password field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The password to edit.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

This works just like [GUILayout.PasswordField](/engine/6000.7/script-reference/unityengine/guilayout/passwordfield.md), but correctly responds to select all, etc. in the editor, and it can have an optional label in front.

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

*Simple window that visualizes what you have typed in the password field.*

### Examples

```csharp
// Editor Script that creates a password field and lets you
// visualize what have you typed in a label.

using UnityEditor;
using UnityEngine;

public class ExampleClass : EditorWindow
{
    string text  = "Some text here";

    [MenuItem("Examples/Editor Password field usage")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        text = EditorGUILayout.PasswordField("Type Something:", text);
        EditorGUILayout.LabelField("Written Text:", text);
    }
}
```

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

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

```csharp
public static string PasswordField(GUIContent label, string password, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label to display in front of the password field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The password to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

This works just like [GUILayout.PasswordField](/engine/6000.7/script-reference/unityengine/guilayout/passwordfield.md), but correctly responds to select all, etc. in the editor, and it can have an optional label in front.

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

*Simple window that visualizes what you have typed in the password field.*

### Examples

```csharp
// Editor Script that creates a password field and lets you
// visualize what have you typed in a label.

using UnityEditor;
using UnityEngine;

public class ExampleClass : EditorWindow
{
    string text  = "Some text here";

    [MenuItem("Examples/Editor Password field usage")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        text = EditorGUILayout.PasswordField("Type Something:", text);
        EditorGUILayout.LabelField("Written Text:", text);
    }
}
```

## PasswordField(GUIContent, string, GUIStyle, GUILayoutOption\[])

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

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

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label to display in front of the password field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The password to edit.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

This works just like [GUILayout.PasswordField](/engine/6000.7/script-reference/unityengine/guilayout/passwordfield.md), but correctly responds to select all, etc. in the editor, and it can have an optional label in front.

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

*Simple window that visualizes what you have typed in the password field.*

### Examples

```csharp
// Editor Script that creates a password field and lets you
// visualize what have you typed in a label.

using UnityEditor;
using UnityEngine;

public class ExampleClass : EditorWindow
{
    string text  = "Some text here";

    [MenuItem("Examples/Editor Password field usage")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        text = EditorGUILayout.PasswordField("Type Something:", text);
        EditorGUILayout.LabelField("Written Text:", text);
    }
}
```
