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.GetNameOfFocusedControl 获取有焦点被命名控件的名字
static function GetNameOfFocusedControl () : String
Description描述
Get the name of named control that has focus.
获取有焦点被命名控件的名字
Control names are set up by using SetNextControlName. When a named control has focus, this function will return its name. If no control has focus or the focused control has no name set returns empty string.
控件名字由SetNextControlName设置,当被命名控件有焦点,这个函数将返回他的名字,如果没有控件获得焦点或有焦点控件没有名字将返回空字符串。
GetNameOfFocusedControl works well when you make a login box.
GetNameOfFocusedControl可以用于创建注册框方面。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public string login = "username";
public string login2 = "no action here";
void OnGUI() {
GUI.SetNextControlName("user");
login = GUI.TextField(new Rect(10, 10, 130, 20), login);
login2 = GUI.TextField(new Rect(10, 40, 130, 20), login2);
if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "user")
Debug.Log("Login");
if (GUI.Button(new Rect(150, 10, 50, 20), "Login"))
Debug.Log("Login");
}
}
var login : String = "username";
var login2 : String = "no action here";
function OnGUI () {
GUI.SetNextControlName ("user");
login = GUI.TextField (Rect (10,10,130,20), login);
login2 = GUI.TextField (Rect (10,40,130,20), login2);
if (Event.current.Equals (Event.KeyboardEvent ("return")) &&
GUI.GetNameOfFocusedControl () == "user") {
Debug.Log("Login");
}
if (GUI.Button(new Rect (150,10,50,20), "Login"))
Debug.Log("Login");
}
最后修改:2011年6月15日 Wednesday 10:50