EditorGUI.ColorField 颜色字段

static function ColorField (position : Rect, value : Color) : Color
static function ColorField (position : Rect, label : string, value : Color) : Color
static function ColorField (position : Rect, label : GUIContent, value : Color) : Color

Parameters参数

Returns

Color - The color selected by the user.

返回Color - 用户输入的值。

Description描述

Make a field for selecting a Color.

制作一个颜色字段,用来选择颜色。

EditorGUI.ColorField 颜色字段

Color field in an Editor Window.
在编辑器窗口中的颜色字段。

// Change The color of the selected Game Objects

//改变的选择游戏物体颜色



class EditorGUIColorField extends EditorWindow {



	var matColor : Color = Color.white;

	@MenuItem("Examples/Massive Color Change")

	static function Init() {

		var window = GetWindow(EditorGUIColorField);

		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;

	}

}
Page last updated: 2011-6-23