EditorGUILayout.ColorField 颜色字段


static function ColorField (value : Color, params options : GUILayoutOption[]) : Color
static function ColorField (label : string, value : Color, params options : GUILayoutOption[]) : Color
static function ColorField (label : GUIContent, value : Color, params options : GUILayoutOption[]) : Color

Parameters参数

  • label
    Optional label in front of the field.  // 字段前面的可选标签。
  • value
    The value to edit. // 编辑的值
  • options
    An optional list of layout options that specify extra layouting   properties. Any values passed in here will override settings defined by   the style.  See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
       指定额外布局属性的可选列表。这里传递任意值,将覆盖样式定义的设置。

Returns

Color - The color selected by the user.

返回Color,由用户输入的值。

Description描述

Make a field for selecting a Color.

制作一个用于选择颜色的字段。

EditorGUILayout.ColorField 颜色字段

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

// Change The color of the selected Game Objects//改变选择游戏物体的颜色。class MassiveColorChange extends EditorWindow {var matColor : Color = Color.white;@MenuItem("Examples/Massive Color Change")static function Init() {var window = GetWindow(MassiveColorChange);window.Show();}function OnGUI() {matColor = EditorGUILayout.ColorField("New Color", matColor);if(GUILayout.Button("Change!"))ChangeColors();}function ChangeColors() {if(Selection.activeGameObject)for(var t in Selection.gameObjects)if(t.renderer)t.renderer.sharedMaterial.color = matColor;}}


,