# RectField

> Make an X, Y, W & H field for entering a Rect.

## Definition

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

## RectField(Rect, GUILayoutOption\[])

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

```csharp
public static Rect RectField(Rect value, params GUILayoutOption[] options)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): The value to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

*Capture the RectField sizes.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;

public class RectFieldExample : EditorWindow
{
    static Rect pos;

    [MenuItem("Examples/RectField Example")]
    static void rectFieldExample()
    {
        RectFieldExample window =
            EditorWindow.GetWindowWithRect<RectFieldExample>(new Rect(0, 0, 250, 100));
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        pos =  EditorGUILayout.RectField("Internal input:", pos);

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("x: " + (pos.x).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("y: " + (pos.y).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("w: " + (pos.width).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("h: " + (pos.height).ToString());
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Close"))
        {
            this.Close();
        }
    }
}
```

## RectField(string, Rect, GUILayoutOption\[])

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

```csharp
public static Rect RectField(string label, Rect value, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label to display above the field.**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): The value to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

*Capture the RectField sizes.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;

public class RectFieldExample : EditorWindow
{
    static Rect pos;

    [MenuItem("Examples/RectField Example")]
    static void rectFieldExample()
    {
        RectFieldExample window =
            EditorWindow.GetWindowWithRect<RectFieldExample>(new Rect(0, 0, 250, 100));
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        pos =  EditorGUILayout.RectField("Internal input:", pos);

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("x: " + (pos.x).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("y: " + (pos.y).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("w: " + (pos.width).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("h: " + (pos.height).ToString());
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Close"))
        {
            this.Close();
        }
    }
}
```

## RectField(GUIContent, Rect, GUILayoutOption\[])

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

```csharp
public static Rect RectField(GUIContent label, Rect value, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Label to display above the field.**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): The value to edit.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

*Capture the RectField sizes.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;

public class RectFieldExample : EditorWindow
{
    static Rect pos;

    [MenuItem("Examples/RectField Example")]
    static void rectFieldExample()
    {
        RectFieldExample window =
            EditorWindow.GetWindowWithRect<RectFieldExample>(new Rect(0, 0, 250, 100));
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        pos =  EditorGUILayout.RectField("Internal input:", pos);

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("x: " + (pos.x).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("y: " + (pos.y).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("w: " + (pos.width).ToString());
        GUILayout.FlexibleSpace();
        GUILayout.Label("h: " + (pos.height).ToString());
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Close"))
        {
            this.Close();
        }
    }
}
```
