EditorUtility.FocusProjectWindow 焦点项目窗口

static function FocusProjectWindow () : void

Description描述

Brings the project window to the front and focuses it.

使项目窗口到前面并焦点它。

This is commonly called after a menu item that creates and selects an asset is invoked.

这个通常在一个菜单项创建并选择一个资源之后被调用。

EditorUtility.FocusProjectWindow 焦点项目窗口

Changes the color of the selected GameObjects.
改变选择游戏物体的颜色。

// Change The color of the selected Game Objects
// and focus the project window after clicking on the
// "Change!" Button.
//改变选择游戏物体的颜色并点击Change!按钮之后,焦点项目窗口
class EditorUtilityFocusProjectWindow extends EditorWindow {

	var matColor : Color = Color.white;
	@MenuItem("Examples/Massive Color Change")
	static function Init() {
		var window = GetWindow(EditorUtilityFocusProjectWindow);
		window.position = Rect(0,0,170,60);
		window.Show();
	}
	function OnGUI() {
		matColor = EditorGUI.ColorField(Rect(3,3,position.width - 6, 15),
			"New Color:",
			matColor);
		if(GUI.Button(Rect(3,25,position.width-6, 30),"Change!"))
			ChangeColors();
	}

	function ChangeColors() {
		if(Selection.activeGameObject) {
			for(var t in Selection.gameObjects)
				if(t.renderer)
					t.renderer.sharedMaterial.color = matColor;
		}
		EditorUtility.FocusProjectWindow();
	}
}
Page last updated: 2011-7-15