Unity - Scripting API: GUILayout.TextField
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Declaration
public static string TextField(string text, params GUILayoutOption[] options);
Declaration
public static string TextField(string text, int maxLength, params GUILayoutOption[] options);
Declaration
public static string TextField(string text, GUIStyle style, params GUILayoutOption[] options);
Declaration
public static string TextField(string text, int maxLength, GUIStyle style, params GUILayoutOption[] options);
Returns
string The edited string.
Description
Make a single-line text field where the user can edit a string.
Text field in the GameView.
using UnityEngine;public class ExampleScript : MonoBehaviour { string stringToEdit = "Hello World";
void OnGUI() { // Make a text field that modifies stringToEdit. stringToEdit = GUILayout.TextField(stringToEdit, 25); } }