言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

GUI.FocusControl

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function FocusControl(name: string): void;
public static void FocusControl(string name);
public static def FocusControl(name as string) as void

Parameters

name SetNextControlName を使用して設定した名前

Description

コントロール名でキーボードのフォーカスを移動させます

See Also: SetNextControlName, GetNameOfFocusedControl. EditorGUIのテキストフィールドにフォーカスさせるには、EditorGUI.FocusTextInControlを参照してください。

	// When pressed the button, selects the "username" Textfield.
	var username : String = "username";
	var pwd : String = "a pwd";
	function OnGUI () {
		// Set the internal name of the textfield
		GUI.SetNextControlName ("MyTextField");
		
		// Make the actual text field.
		username = GUI.TextField (Rect (10,10,100,20), username);
		pwd = GUI.TextField (Rect (10,40,100,20), pwd);

		// If the user presses this button, keyboard focus will move.
		if (GUI.Button (Rect (10,70,80,20), "Move Focus"))
			GUI.FocusControl ("MyTextField");	
	}
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");
        
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public username as string = 'username'

	public pwd as string = 'a pwd'

	def OnGUI() as void:
		GUI.SetNextControlName('MyTextField')
		username = GUI.TextField(Rect(10, 10, 100, 20), username)
		pwd = GUI.TextField(Rect(10, 40, 100, 20), pwd)
		if GUI.Button(Rect(10, 70, 80, 20), 'Move Focus'):
			GUI.FocusControl('MyTextField')