# ColorField

> Make a field for selecting a Color.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.3/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

## ColorField(Color, GUILayoutOption\[])

Make a field for selecting a [Color](/engine/6000.3/script-reference/unityengine/color.md).

```csharp
public static Color ColorField(Color value, params GUILayoutOption[] options)
```

### Parameters

**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.3/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [Color](/engine/6000.3/script-reference/unityengine/color.md) | The color selected by the user. |

### Remarks

![MassiveColorChange (ColorField)](/api/media?file=/engine/6000.3/media/images/MassiveColorChange.png)

*Change the color of the selected GameObjects.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Change the color of the selected GameObjects.

public class ExampleClass : EditorWindow
{
    Color matColor = Color.white;

    [MenuItem("Examples/Mass Color Change")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        matColor = EditorGUILayout.ColorField("New Color", matColor);

        if (GUILayout.Button("Change!"))
            ChangeColors();
    }

    private void ChangeColors()
    {
        if (Selection.activeGameObject)
            foreach (GameObject t in Selection.gameObjects)
            {
                Renderer rend = t.GetComponent<Renderer>();

                if (rend != null)
                    rend.sharedMaterial.color = matColor;
            }
    }
}
```

## ColorField(string, Color, GUILayoutOption\[])

Make a field for selecting a [Color](/engine/6000.3/script-reference/unityengine/color.md).

```csharp
public static Color ColorField(string label, Color value, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the field.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.3/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [Color](/engine/6000.3/script-reference/unityengine/color.md) | The color selected by the user. |

### Remarks

![MassiveColorChange (ColorField)](/api/media?file=/engine/6000.3/media/images/MassiveColorChange.png)

*Change the color of the selected GameObjects.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Change the color of the selected GameObjects.

public class ExampleClass : EditorWindow
{
    Color matColor = Color.white;

    [MenuItem("Examples/Mass Color Change")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        matColor = EditorGUILayout.ColorField("New Color", matColor);

        if (GUILayout.Button("Change!"))
            ChangeColors();
    }

    private void ChangeColors()
    {
        if (Selection.activeGameObject)
            foreach (GameObject t in Selection.gameObjects)
            {
                Renderer rend = t.GetComponent<Renderer>();

                if (rend != null)
                    rend.sharedMaterial.color = matColor;
            }
    }
}
```

## ColorField(GUIContent, Color, GUILayoutOption\[])

Make a field for selecting a [Color](/engine/6000.3/script-reference/unityengine/color.md).

```csharp
public static Color ColorField(GUIContent label, Color value, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.3/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [Color](/engine/6000.3/script-reference/unityengine/color.md) | The color selected by the user. |

### Remarks

![MassiveColorChange (ColorField)](/api/media?file=/engine/6000.3/media/images/MassiveColorChange.png)

*Change the color of the selected GameObjects.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Change the color of the selected GameObjects.

public class ExampleClass : EditorWindow
{
    Color matColor = Color.white;

    [MenuItem("Examples/Mass Color Change")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        matColor = EditorGUILayout.ColorField("New Color", matColor);

        if (GUILayout.Button("Change!"))
            ChangeColors();
    }

    private void ChangeColors()
    {
        if (Selection.activeGameObject)
            foreach (GameObject t in Selection.gameObjects)
            {
                Renderer rend = t.GetComponent<Renderer>();

                if (rend != null)
                    rend.sharedMaterial.color = matColor;
            }
    }
}
```

## ColorField(GUIContent, Color, bool, bool, bool, ColorPickerHDRConfig, GUILayoutOption\[])

Make a field for selecting a [Color](/engine/6000.3/script-reference/unityengine/color.md).

> **Warning:**
>
> **Deprecated.** Use EditorGUILayout.ColorField(GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, params GUILayoutOption\[] options)

```csharp
public static Color ColorField(GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, ColorPickerHDRConfig hdrConfig, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to edit.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, the color picker should show the eyedropper control. If false, don't show it.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, allow the user to set an alpha value for the color. If false, hide the alpha component.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, treat the color as an HDR value. If false, treat it as a standard LDR value.**** (\[ColorPickerHDRConfig]\(/engine/6000.3/script-reference/unityeditor/colorpickerhdrconfig)): **** (\[GUILayoutOption\[]]\(/engine/6000.3/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [Color](/engine/6000.3/script-reference/unityengine/color.md) | The color selected by the user. |

### Remarks

![MassiveColorChange (ColorField)](/api/media?file=/engine/6000.3/media/images/MassiveColorChange.png)

*Change the color of the selected GameObjects.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Change the color of the selected GameObjects.

public class ExampleClass : EditorWindow
{
    Color matColor = Color.white;

    [MenuItem("Examples/Mass Color Change")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        matColor = EditorGUILayout.ColorField("New Color", matColor);

        if (GUILayout.Button("Change!"))
            ChangeColors();
    }

    private void ChangeColors()
    {
        if (Selection.activeGameObject)
            foreach (GameObject t in Selection.gameObjects)
            {
                Renderer rend = t.GetComponent<Renderer>();

                if (rend != null)
                    rend.sharedMaterial.color = matColor;
            }
    }
}
```

## ColorField(GUIContent, Color, bool, bool, bool, GUILayoutOption\[])

Make a field for selecting a [Color](/engine/6000.3/script-reference/unityengine/color.md).

```csharp
public static Color ColorField(GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[Color]\(/engine/6000.3/script-reference/unityengine/color)): The color to edit.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, the color picker should show the eyedropper control. If false, don't show it.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, allow the user to set an alpha value for the color. If false, hide the alpha component.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, treat the color as an HDR value. If false, treat it as a standard LDR value.**** (\[GUILayoutOption\[]]\(/engine/6000.3/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [Color](/engine/6000.3/script-reference/unityengine/color.md) | The color selected by the user. |

### Remarks

![MassiveColorChange (ColorField)](/api/media?file=/engine/6000.3/media/images/MassiveColorChange.png)

*Change the color of the selected GameObjects.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Change the color of the selected GameObjects.

public class ExampleClass : EditorWindow
{
    Color matColor = Color.white;

    [MenuItem("Examples/Mass Color Change")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        matColor = EditorGUILayout.ColorField("New Color", matColor);

        if (GUILayout.Button("Change!"))
            ChangeColors();
    }

    private void ChangeColors()
    {
        if (Selection.activeGameObject)
            foreach (GameObject t in Selection.gameObjects)
            {
                Renderer rend = t.GetComponent<Renderer>();

                if (rend != null)
                    rend.sharedMaterial.color = matColor;
            }
    }
}
```
