# GradientField

> Makes a field for editing a Gradient.

## Definition

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

## GradientField(Rect, Gradient)

Makes a field for editing a [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md).

```csharp
public static Gradient GradientField(Rect position, Gradient gradient)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[Gradient]\(/engine/6000.0/script-reference/unityengine/gradient)): The gradient to edit.

### Returns

| Type                                                                | Description                      |
| ------------------------------------------------------------------- | -------------------------------- |
| [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md) | The gradient edited by the user. |

### Examples

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUIGradientField : EditorWindow
{
    Gradient gradient = new Gradient();

    [MenuItem("Examples/Gradient Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUIGradientField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        gradient = EditorGUI.GradientField(
            new Rect(3, 3, position.width - 6, 50), "Gradient", gradient);
    }
}
```

## GradientField(Rect, string, Gradient)

Makes a field for editing a [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md).

```csharp
public static Gradient GradientField(Rect position, string label, Gradient gradient)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display in front of the field.**** (\[Gradient]\(/engine/6000.0/script-reference/unityengine/gradient)): The gradient to edit.

### Returns

| Type                                                                | Description                      |
| ------------------------------------------------------------------- | -------------------------------- |
| [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md) | The gradient edited by the user. |

### Examples

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUIGradientField : EditorWindow
{
    Gradient gradient = new Gradient();

    [MenuItem("Examples/Gradient Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUIGradientField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        gradient = EditorGUI.GradientField(
            new Rect(3, 3, position.width - 6, 50), "Gradient", gradient);
    }
}
```

## GradientField(Rect, GUIContent, Gradient)

Makes a field for editing a [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md).

```csharp
public static Gradient GradientField(Rect position, GUIContent label, Gradient gradient)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[Gradient]\(/engine/6000.0/script-reference/unityengine/gradient)): The gradient to edit.

### Returns

| Type                                                                | Description                      |
| ------------------------------------------------------------------- | -------------------------------- |
| [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md) | The gradient edited by the user. |

### Examples

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUIGradientField : EditorWindow
{
    Gradient gradient = new Gradient();

    [MenuItem("Examples/Gradient Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUIGradientField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        gradient = EditorGUI.GradientField(
            new Rect(3, 3, position.width - 6, 50), "Gradient", gradient);
    }
}
```

## GradientField(Rect, GUIContent, Gradient, bool)

Makes a field for editing a [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md).

```csharp
public static Gradient GradientField(Rect position, GUIContent label, Gradient gradient, bool hdr)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[Gradient]\(/engine/6000.0/script-reference/unityengine/gradient)): The gradient to edit.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Display the HDR Gradient Editor.

### Returns

| Type                                                                | Description                      |
| ------------------------------------------------------------------- | -------------------------------- |
| [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md) | The gradient edited by the user. |

### Examples

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUIGradientField : EditorWindow
{
    Gradient gradient = new Gradient();

    [MenuItem("Examples/Gradient Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUIGradientField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        gradient = EditorGUI.GradientField(
            new Rect(3, 3, position.width - 6, 50), "Gradient", gradient);
    }
}
```

## GradientField(Rect, GUIContent, Gradient, bool, ColorSpace)

Makes a field for editing a [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md).

```csharp
public static Gradient GradientField(Rect position, GUIContent label, Gradient gradient, bool hdr, ColorSpace colorSpace)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label to display in front of the field.**** (\[Gradient]\(/engine/6000.0/script-reference/unityengine/gradient)): The gradient to edit.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Display the HDR Gradient Editor.**** (\[ColorSpace]\(/engine/6000.0/script-reference/unityengine/colorspace)): Display the gradient and Gradient Editor in this color space.

### Returns

| Type                                                                | Description                      |
| ------------------------------------------------------------------- | -------------------------------- |
| [Gradient](/engine/6000.0/script-reference/unityengine/gradient.md) | The gradient edited by the user. |

### Examples

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUIGradientField : EditorWindow
{
    Gradient gradient = new Gradient();

    [MenuItem("Examples/Gradient Field demo")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUIGradientField));
        window.position = new Rect(0, 0, 400, 199);
        window.Show();
    }

    void OnGUI()
    {
        gradient = EditorGUI.GradientField(
            new Rect(3, 3, position.width - 6, 50), "Gradient", gradient);
    }
}
```
