Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TextField

Make a text field.
Read time 7 minutesLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

TextField(string, GUILayoutOption[])

Make a text field.
public static string TextField(string text, params GUILayoutOption[] options)

Parameters

text

The text to edit.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the
style
.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

stringThe text entered by the user.

Remarks

This works just like GUILayout.TextField, but correctly responds to select all, copy, paste etc. in the editor, and it can have an optional label in front.
EditorGUILayoutTextField (TextField)
Changes the name of the selected GameObject.

Examples

// Automatically change the name of the selected object via a text fieldusing 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.
public static string TextField(string text, GUIStyle style, params GUILayoutOption[] options)

Parameters

text

The text to edit.

Optional GUIStyle.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the
style
.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

stringThe text entered by the user.

Remarks

This works just like GUILayout.TextField, but correctly responds to select all, copy, paste etc. in the editor, and it can have an optional label in front.
EditorGUILayoutTextField (TextField)
Changes the name of the selected GameObject.

Examples

// Automatically change the name of the selected object via a text fieldusing 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.
public static string TextField(string label, string text, params GUILayoutOption[] options)

Parameters

label

Optional label to display in front of the text field.

text

The text to edit.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the
style
.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

stringThe text entered by the user.

Remarks

This works just like GUILayout.TextField, but correctly responds to select all, copy, paste etc. in the editor, and it can have an optional label in front.
EditorGUILayoutTextField (TextField)
Changes the name of the selected GameObject.

Examples

// Automatically change the name of the selected object via a text fieldusing 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.
public static string TextField(string label, string text, GUIStyle style, params GUILayoutOption[] options)

Parameters

label

Optional label to display in front of the text field.

text

The text to edit.

Optional GUIStyle.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the
style
.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

stringThe text entered by the user.

Remarks

This works just like GUILayout.TextField, but correctly responds to select all, copy, paste etc. in the editor, and it can have an optional label in front.
EditorGUILayoutTextField (TextField)
Changes the name of the selected GameObject.

Examples

// Automatically change the name of the selected object via a text fieldusing 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.
public static string TextField(GUIContent label, string text, params GUILayoutOption[] options)

Parameters

Optional label to display in front of the text field.

text

The text to edit.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the
style
.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

stringThe text entered by the user.

Remarks

This works just like GUILayout.TextField, but correctly responds to select all, copy, paste etc. in the editor, and it can have an optional label in front.
EditorGUILayoutTextField (TextField)
Changes the name of the selected GameObject.

Examples

// Automatically change the name of the selected object via a text fieldusing 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.
public static string TextField(GUIContent label, string text, GUIStyle style, params GUILayoutOption[] options)

Parameters

Optional label to display in front of the text field.

text

The text to edit.

Optional GUIStyle.

An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the
style
.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

Type

Description

stringThe text entered by the user.

Remarks

This works just like GUILayout.TextField, but correctly responds to select all, copy, paste etc. in the editor, and it can have an optional label in front.
EditorGUILayoutTextField (TextField)
Changes the name of the selected GameObject.

Examples

// Automatically change the name of the selected object via a text fieldusing 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(); }}