Version: 2021.1
public static string TextArea (string text, params GUILayoutOption[] options);
public static string TextArea (string text, int maxLength, params GUILayoutOption[] options);
public static string TextArea (string text, GUIStyle style, params GUILayoutOption[] options);
public static string TextArea (string text, int maxLength, GUIStyle style, params GUILayoutOption[] options);

参数

text 要编辑的文本。应将该函数的返回值指定给该字符串,如示例中所示。
maxLength 字符串的最大长度。如果省略,用户可以键入任意长度的字符串。
style 要使用的样式。如果省略,则使用当前 GUISkintextField 样式。
options (可选)一个布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。<br> 另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

返回

string 编辑后的字符串。

描述

创建一个可供用户编辑字符串的多行文本字段。

\ 游戏视图中的文本区域。

using UnityEngine;

public class ExampleScript : MonoBehaviour { string stringToEdit = "Hello World\nI've got 2 lines...";

void OnGUI() { // Make a multiline text area that modifies stringToEdit. stringToEdit = GUILayout.TextArea(stringToEdit, 200); } }