Unity 6.3
0 онлайн 2 гостей 3 в системе
Вход

GUI.FocusControl

Declaration

public static void FocusControl(string name);

Параметры

Параметр Описание
имя Набор имен с использованием SetNextControlName.

Описание

Перемещение фокуса клавиатуры на именованный элемент управления.

Дополнительные ресурсы: SetNextControlName, GetNameOfFocusedControl.

Для фокусирования текста в текстовых полях Редактора GUI, см. EditorGUI.FocusTextInControl.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { // When pressed the button, selects the "username" Textfield. public string username = "username"; public string pwd = "a pwd";

void OnGUI() { // Set the internal name of the textfield GUI.SetNextControlName("MyTextField");

// Make the actual text field. username = GUI.TextField(new Rect(10, 10, 100, 20), username); pwd = GUI.TextField(new Rect(10, 40, 100, 20), pwd);

// If the user presses this button, keyboard focus will move. if (GUI.Button(new Rect(10, 70, 80, 20), "Move Focus")) GUI.FocusControl("MyTextField"); } }