UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUILayout.TextField
# [GUILayout](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.html).TextField public static string **TextField** (string **text**, params GUILayoutOption[] **options**); public static string **TextField** (string **text**, int **maxLength**, params GUILayoutOption[] **options**); public static string **TextField** (string **text**, [GUIStyle](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIStyle.html) **style**, params GUILayoutOption[] **options**); public static string **TextField** (string **text**, int **maxLength**, [GUIStyle](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIStyle.html) **style**, params GUILayoutOption[] **options**); ## 参数 | text | 要编辑的文本。应将该函数的返回值指定给该字符串,如示例中所示。 | | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | maxLength | 字符串的最大长度。如果省略,用户可以键入任意长度的字符串。 | | style | 要使用的样式。如果省略,则使用当前 [GUISkin](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUISkin.html) 的 `textArea` 样式。 | | options | (可选)一个布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 `style` 定义的设置。另请参阅:[GUILayout.Width](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.Width.html)、[GUILayout.Height](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.Height.html)、[GUILayout.MinWidth](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MinWidth.html)、[GUILayout.MaxWidth](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MaxWidth.html)、[GUILayout.MinHeight](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MinHeight.html)、 [GUILayout.MaxHeight](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MaxHeight.html)、[GUILayout.ExpandWidth](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.ExpandWidth.html)、[GUILayout.ExpandHeight](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.ExpandHeight.html)。 | ## 返回 **string** 编辑后的字符串。 ## 描述 创建一个可供用户编辑字符串的单行文本字段。  \ *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); } } ```
da
2022年6月10日 00:15
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码