Version: 5.3

GUI.FocusControl

매뉴얼로 전환
public static void FocusControl (string name);

파라미터

name Name set using SetNextControlName.

설명

Move keyboard focus to a named control.

See Also: SetNextControlName, GetNameOfFocusedControl.

For focusing text in Editor GUI text fields, see EditorGUI.FocusTextInControl.

using UnityEngine;
using System.Collections;

public class ExampleClass : 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"); } }