GUI
- backgroundColor
- BeginGroup
- BeginScrollView
- Box
- BringWindowToBack
- BringWindowToFront
- Button
- changed
- color
- contentColor
- depth
- DragWindow
- DrawTexture
- enabled
- EndGroup
- EndScrollView
- FocusControl
- FocusWindow
- GetNameOfFocusedControl
- GUI
- HorizontalScrollbar
- HorizontalSlider
- Label
- matrix
- PasswordField
- RepeatButton
- ScrollTo
- SelectionGrid
- SetNextControlName
- skin
- TextArea
- TextField
- Toggle
- Toolbar
- tooltip
- UnfocusWindow
- VerticalScrollbar
- VerticalSlider
- Window
GUI.TextField 文本字段
static function TextField (position : Rect, text : String) : String
static function TextField (position : Rect, text : String, maxLength : int) : String
static function TextField (position : Rect, text : String, style : GUIStyle) : String
static function TextField (position : Rect, text : String, maxLength : int, style : GUIStyle) : String
Parameters参数
- positionRectangle on the screen to use for the text field.
用于文本字段在屏幕上矩形的位置。 - 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 textField style from the current GUISkin is used.
使用样式,如果不设置,文本字段的样式将应用当前的GUISkin皮肤。
string - the edited string.
返回被编辑的字符串。
Description描述
Make a single-line text field where the user can edit a string.
创建单行文本字段,用户可以编辑字符串。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public string stringToEdit = "Hello World";
void OnGUI() {
stringToEdit = GUI.TextField (new Rect(10, 10, 200, 20), stringToEdit, 25);
}
}
var stringToEdit : String = "Hello World";
function OnGUI () {
// 创建一个文本字段,用户可以修改编辑。
stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 25);
}
最后修改:2010年12月2日 Thursday 22:42