Version: 2020.2
言語: 日本語
public static void FocusTextInControl (string name);

パラメーター

name GUI.SetNextControlName を使用して Name を設定します。

説明

名前付きのテキストフィールドにキーボードフォーカスを移動し、コンテンツの編集を開始します。

Editor GUI ではテキストフィールドはテキスト編集なしでキーボードフォーカスを持つことができます。たとえば上下の矢印キーを使用してテキストフィールド間や他の制御間のフォーカスを切り替えることがあるかもしれません。テキストフィールド内をクリックし、それ自身のテキストの編集を開始します。テキストの内容を移動するために矢印キーを使用します。 EditorGUI.FocusTextInControl はキーボードフォーカスを制御に与える GUI.FocusControl のようですが、テキスト自体の編集を開始します。

See Also: GUI.SetNextControlName, GUI.GetNameOfFocusedControl.

using UnityEngine;
using UnityEditor;

public class Example : EditorWindow { // When pressed the button, selects the "username" Textfield. string username = "username"; string pwd = "a pwd"; void OnInspectorGUI() { // Set the internal name of the textfield GUI.SetNextControlName("MyTextField");

// Make the actual text field. username = EditorGUI.TextField(new Rect(10, 10, 100, 20), username); pwd = EditorGUI.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")) { EditorGUI.FocusTextInControl("MyTextField"); } } }