# TextField

> Make a text field.

## Definition

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

## TextField(string, GUILayoutOption\[])

Make a text field.

```csharp
public static string TextField(string text, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.5/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.5/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.5/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.5/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.5/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.5/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.5/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.5/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.5/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

![EditorGUILayoutTextField (TextField)](/api/media?file=/engine/6000.5/media/images/EditorGUILayoutTextField.png)

*Changes the name of the selected GameObject.*

### Examples

```csharp
// Automatically change the name of the selected object via a text field
using UnityEditor;
using UnityEngine;

public class EditorGUILayoutTextField : EditorWindow
{
    [MenuItem("Examples/GUILayout TextField")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutTextField));
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select an object in the hierarchy view");
        if (Selection.activeGameObject)
            Selection.activeGameObject.name =
                EditorGUILayout.TextField("Object Name: ", Selection.activeGameObject.name);
        this.Repaint();
    }
}
```

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

Make a text field.

```csharp
public static string TextField(string text, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text to edit.**** (\[GUIStyle]\(/engine/6000.5/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.5/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.5/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.5/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.5/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.5/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.5/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.5/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.5/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.5/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.5/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

![EditorGUILayoutTextField (TextField)](/api/media?file=/engine/6000.5/media/images/EditorGUILayoutTextField.png)

*Changes the name of the selected GameObject.*

### Examples

```csharp
// Automatically change the name of the selected object via a text field
using UnityEditor;
using UnityEngine;

public class EditorGUILayoutTextField : EditorWindow
{
    [MenuItem("Examples/GUILayout TextField")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutTextField));
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select an object in the hierarchy view");
        if (Selection.activeGameObject)
            Selection.activeGameObject.name =
                EditorGUILayout.TextField("Object Name: ", Selection.activeGameObject.name);
        this.Repaint();
    }
}
```

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

Make a text field.

```csharp
public static string TextField(string label, string text, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the text field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.5/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.5/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.5/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.5/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.5/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.5/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.5/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.5/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.5/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

![EditorGUILayoutTextField (TextField)](/api/media?file=/engine/6000.5/media/images/EditorGUILayoutTextField.png)

*Changes the name of the selected GameObject.*

### Examples

```csharp
// Automatically change the name of the selected object via a text field
using UnityEditor;
using UnityEngine;

public class EditorGUILayoutTextField : EditorWindow
{
    [MenuItem("Examples/GUILayout TextField")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutTextField));
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select an object in the hierarchy view");
        if (Selection.activeGameObject)
            Selection.activeGameObject.name =
                EditorGUILayout.TextField("Object Name: ", Selection.activeGameObject.name);
        this.Repaint();
    }
}
```

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

Make a text field.

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the text field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text to edit.**** (\[GUIStyle]\(/engine/6000.5/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.5/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.5/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.5/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.5/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.5/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.5/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.5/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.5/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.5/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.5/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

![EditorGUILayoutTextField (TextField)](/api/media?file=/engine/6000.5/media/images/EditorGUILayoutTextField.png)

*Changes the name of the selected GameObject.*

### Examples

```csharp
// Automatically change the name of the selected object via a text field
using UnityEditor;
using UnityEngine;

public class EditorGUILayoutTextField : EditorWindow
{
    [MenuItem("Examples/GUILayout TextField")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutTextField));
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select an object in the hierarchy view");
        if (Selection.activeGameObject)
            Selection.activeGameObject.name =
                EditorGUILayout.TextField("Object Name: ", Selection.activeGameObject.name);
        this.Repaint();
    }
}
```

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

Make a text field.

```csharp
public static string TextField(GUIContent label, string text, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.5/script-reference/unityengine/guicontent)): Optional label to display in front of the text field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.5/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.5/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.5/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.5/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.5/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.5/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.5/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.5/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.5/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

![EditorGUILayoutTextField (TextField)](/api/media?file=/engine/6000.5/media/images/EditorGUILayoutTextField.png)

*Changes the name of the selected GameObject.*

### Examples

```csharp
// Automatically change the name of the selected object via a text field
using UnityEditor;
using UnityEngine;

public class EditorGUILayoutTextField : EditorWindow
{
    [MenuItem("Examples/GUILayout TextField")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutTextField));
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select an object in the hierarchy view");
        if (Selection.activeGameObject)
            Selection.activeGameObject.name =
                EditorGUILayout.TextField("Object Name: ", Selection.activeGameObject.name);
        this.Repaint();
    }
}
```

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

Make a text field.

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

### Parameters

**** (\[GUIContent]\(/engine/6000.5/script-reference/unityengine/guicontent)): Optional label to display in front of the text field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text to edit.**** (\[GUIStyle]\(/engine/6000.5/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.5/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.5/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.5/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.5/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.5/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.5/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.5/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.5/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.5/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.5/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

![EditorGUILayoutTextField (TextField)](/api/media?file=/engine/6000.5/media/images/EditorGUILayoutTextField.png)

*Changes the name of the selected GameObject.*

### Examples

```csharp
// Automatically change the name of the selected object via a text field
using UnityEditor;
using UnityEngine;

public class EditorGUILayoutTextField : EditorWindow
{
    [MenuItem("Examples/GUILayout TextField")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutTextField));
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select an object in the hierarchy view");
        if (Selection.activeGameObject)
            Selection.activeGameObject.name =
                EditorGUILayout.TextField("Object Name: ", Selection.activeGameObject.name);
        this.Repaint();
    }
}
```
