概要
using UnityEditor; using UnityEngine; public sealed class Example : EditorWindow { private bool m_isInitialized; private string m_name; [MenuItem( "Tools/Hoge" )] public static void Open() { GetWindow<Example>(); } private void OnGUI() { GUI.SetNextControlName( "Name" ); m_name = EditorGUILayout.TextField( "名前", m_name ); if ( m_isInitialized ) return; EditorGUI.FocusTextInControl( "Name" ); m_isInitialized = true; } }
GUI.SetNextControlName
で GUI の要素に名前をつけて
EditorGUI.FocusTextInControl
でその名前を指定する