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.FocusControl 焦点控件
static function FocusControl (name : String) : void
Description描述
Move keyboard focus to a named control.
移动键盘焦点到被命名的控件。
参考:SetNextControlName, GetNameOfFocusedControl.
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public string username = "username";
public string pwd = "a pwd";
void OnGUI() {
GUI.SetNextControlName("MyTextField");
username = GUI.TextField(new Rect(10, 10, 100, 20), username);
pwd = GUI.TextField(new Rect(10, 40, 100, 20), pwd);
if (GUI.Button(new Rect(10, 70, 80, 20), "Move Focus"))
GUI.FocusControl("MyTextField");
}
}
//当按下按钮,选择"username"文本字段,也就是获得焦点
var username : String = "username";
var pwd : String = "a pwd";
function OnGUI () {
//设置文本字段一个内部名字
GUI.SetNextControlName ("MyTextField");
//创建用户名和密码文本字段
username = GUI.TextField (Rect (10,10,100,20), username);
pwd = GUI.TextField (Rect (10,40,100,20), pwd);
// 如果按下按钮键盘焦点将移动到用户名文本字段
if (GUI.Button (Rect (10,70,80,20), "Move Focus"))
GUI.FocusControl ("MyTextField");
}
最后修改:2011年1月14日 Friday 21:18