# RectField

> Makes an X, Y, W, and H field for entering a Rect.

## Definition

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

## RectField(Rect, Rect)

Makes an X, Y, W, and H field for entering a [Rect](/engine/6000.7/script-reference/unityengine/rect.md).

```csharp
public static Rect RectField(Rect position, Rect value)
```

### Parameters

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

### Returns

| Type                                                        | Description                    |
| ----------------------------------------------------------- | ------------------------------ |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The value entered by the user. |

### Remarks

![EditorGUIRectField (RectField)](/api/media?file=/engine/6000.7/media/images/EditorGUIRectField.png)

*Rect field in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Find all the cameras in the Scene and shows all their viewports togheter

class EditorGUIRectField : EditorWindow
{
    Camera[] cameras;

    [MenuItem("Examples/Editor GUI RectField usage")]
    static void Init()
    {
        var window = GetWindow<EditorGUIRectField>();
        window.position = new Rect(0, 0, 150, 120);
        window.Show();
    }

    void OnGUI()
    {
        if (GUI.Button(new Rect(3, 3, position.width - 6, 20), "Update list"))
            cameras = FindObjectsOfType<Camera>();

        if (cameras.Length > 0)
        {
            for (var i = 0; i < cameras.Length; i++)
            {
                cameras[i].rect = EditorGUI.RectField(
                    new Rect(3, 25 + 45 * i, position.width - 6, 25),
                    cameras[i].name,
                    cameras[i].rect);
            }
        }
    }
}
```

## RectField(Rect, string, Rect)

Makes an X, Y, W, and H field for entering a [Rect](/engine/6000.7/script-reference/unityengine/rect.md).

```csharp
public static Rect RectField(Rect position, string label, Rect value)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/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 above the field.**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): The value to edit.

### Returns

| Type                                                        | Description                    |
| ----------------------------------------------------------- | ------------------------------ |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The value entered by the user. |

### Remarks

![EditorGUIRectField (RectField)](/api/media?file=/engine/6000.7/media/images/EditorGUIRectField.png)

*Rect field in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Find all the cameras in the Scene and shows all their viewports togheter

class EditorGUIRectField : EditorWindow
{
    Camera[] cameras;

    [MenuItem("Examples/Editor GUI RectField usage")]
    static void Init()
    {
        var window = GetWindow<EditorGUIRectField>();
        window.position = new Rect(0, 0, 150, 120);
        window.Show();
    }

    void OnGUI()
    {
        if (GUI.Button(new Rect(3, 3, position.width - 6, 20), "Update list"))
            cameras = FindObjectsOfType<Camera>();

        if (cameras.Length > 0)
        {
            for (var i = 0; i < cameras.Length; i++)
            {
                cameras[i].rect = EditorGUI.RectField(
                    new Rect(3, 25 + 45 * i, position.width - 6, 25),
                    cameras[i].name,
                    cameras[i].rect);
            }
        }
    }
}
```

## RectField(Rect, GUIContent, Rect)

Makes an X, Y, W, and H field for entering a [Rect](/engine/6000.7/script-reference/unityengine/rect.md).

```csharp
public static Rect RectField(Rect position, GUIContent label, Rect value)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label to display above the field.**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): The value to edit.

### Returns

| Type                                                        | Description                    |
| ----------------------------------------------------------- | ------------------------------ |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The value entered by the user. |

### Remarks

![EditorGUIRectField (RectField)](/api/media?file=/engine/6000.7/media/images/EditorGUIRectField.png)

*Rect field in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

// Find all the cameras in the Scene and shows all their viewports togheter

class EditorGUIRectField : EditorWindow
{
    Camera[] cameras;

    [MenuItem("Examples/Editor GUI RectField usage")]
    static void Init()
    {
        var window = GetWindow<EditorGUIRectField>();
        window.position = new Rect(0, 0, 150, 120);
        window.Show();
    }

    void OnGUI()
    {
        if (GUI.Button(new Rect(3, 3, position.width - 6, 20), "Update list"))
            cameras = FindObjectsOfType<Camera>();

        if (cameras.Length > 0)
        {
            for (var i = 0; i < cameras.Length; i++)
            {
                cameras[i].rect = EditorGUI.RectField(
                    new Rect(3, 25 + 45 * i, position.width - 6, 25),
                    cameras[i].name,
                    cameras[i].rect);
            }
        }
    }
}
```
