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

スクリプト言語

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

EditorWindow.Focus

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 function Focus(): void;
public void Focus();
public def Focus() as void

Description

エディタウィンドウにキーボードフォーカスを当てます

See Also: focusedWindow.
他のウィンドウにあるボタンを押して該当のウィンドウにフォーカスを当てます

	// Simple Editor Window that when clicked focuses another window.
	//
	// Usage: Open both windows (Window 1 and Window 2) and just press the button
	// to see how the focus changes

	class Window1 extends EditorWindow {
	
		static var instance;
	
		@MenuItem("Example/Show Focus Usage/Window1")
		static function Init() {
			var window = EditorWindow.GetWindow(Window1);
		}
	
		function Window1() {
			instance = this;
		}
		
		function OnGUI() {
			if(GUILayout.Button("Focus the other window!")) {
				Window2.instance.Focus();
			}
		}
	}

他の例:

	// Simple Editor Window that when clicked focuses another window.
	//
	// Usage: Open both windows (Window 1 and Window 2) and just press the button
	// to see how the focus changes
	
	class Window2 extends EditorWindow {
		
		static var instance;
		
		@MenuItem("Example/Show Focus Usage/Window2")
		static function Init() {
			var window = EditorWindow.GetWindow(Window2);
		}
		
		function Window2() {
			instance = this;
		}
		
		function OnGUI() {
			if(GUILayout.Button("Focus the other window!")) {
				Window1.instance.Focus();
			}
		}
	}