EditorWindow.Focus 焦点

function Focus () : void

Description描述

Moves keyboard focus to this EditorWindow.

移动键盘焦点到这个编辑器窗口。

参见: focusedWindow.

EditorWindow.Focus 焦点

Focus one window by pressing the button on other window.
通过按另一个窗口上的按钮焦点一个窗口。

// 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();
		}
	}
}
最后修改:2011年6月20日 Monday 14:12

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。