GUILayout
- BeginArea
- BeginHorizontal
- BeginScrollView
- BeginVertical
- Box
- Button
- EndArea
- EndHorizontal
- EndScrollView
- EndVertical
- ExpandHeight
- ExpandWidth
- FlexibleSpace
- Height
- HorizontalScrollbar
- HorizontalSlider
- Label
- MaxHeight
- MaxWidth
- MinHeight
- MinWidth
- PasswordField
- RepeatButton
- SelectionGrid
- Space
- TextArea
- TextField
- Toggle
- Toolbar
- VerticalScrollbar
- VerticalSlider
- Width
- Window
GUILayout.TextField 文本字段
static function TextField (text : string, params options : GUILayoutOption[]) : string
static function TextField (text : string, maxLength : int, params options : GUILayoutOption[]) : string
static function TextField (text : string, style : GUIStyle, params options : GUILayoutOption[]) : string
static function TextField (text : string, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : string
Parameters参数
-
textText to edit. The return value of this function should be assigned back to the string as shown in the example.
可编辑文本,这个函数的返回值应该赋回给这个字符串 -
maxLengthThe maximum length of the string. If left out, the user can type for ever and ever.
字符串的最大长度,如果不设置,用户将可以永远输入下去。 -
styleThe style to use. If left out, the textArea style from the current GUISkin is used.
使用的样式。如果不使用,该文本字段使用当前的GUISkin皮肤 -
optionsAn optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
布局选项指定额外布局属性的一个可选列表。这里传递任意值都将覆盖由style定义的设置。
参考: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
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;
using System.Collections;
public class example : MonoBehaviour {
public string stringToEdit = "Hello World";
void OnGUI() {
stringToEdit = GUILayout.TextField(stringToEdit, 25);
}
}
var stringToEdit : String = "Hello World";
function OnGUI () {
// Make a text field that modifies stringToEdit.
//创建一个文本字段,用户可以修改字符串
stringToEdit = GUILayout.TextField (stringToEdit, 25);
}
最后修改:2011年6月14日 Tuesday 14:43