# GetControlRect

> Get a rect for an Editor control.

## Definition

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

## GetControlRect(GUILayoutOption\[])

Get a rect for an Editor control.

```csharp
public static Rect GetControlRect(params GUILayoutOption[] options)
```

### Parameters

**** (\[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`. 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 |
| ----------------------------------------------------------- | ----------- |
| [Rect](/engine/6000.3/script-reference/unityengine/rect.md) |             |

### Remarks

When creating a new Editor control it is a sound design to implement the actual control without relying on GUILayout and instead have the control take a [Rect](/engine/6000.3/script-reference/unityengine/rect.md) as parameter, similar to the controls in the [EditorGUI](/engine/6000.3/script-reference/unityeditor/editorgui.md) class. This ensures the control can also be used in for example a [PropertyDrawer](/engine/6000.3/script-reference/unityeditor/propertydrawer.md), which does not allow GUILayout.

Once a non-layout version of the control is implemented, a layout version can easily be made as well, which simply calls into the non-layout version. In order to get a rect fitting for the control, the GetControlRect function can be used.

## GetControlRect(bool, GUILayoutOption\[])

Get a rect for an Editor control.

```csharp
public static Rect GetControlRect(bool hasLabel, params GUILayoutOption[] options)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Optional boolean to specify if the control has a label. Default is true.**** (\[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`. 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 |
| ----------------------------------------------------------- | ----------- |
| [Rect](/engine/6000.3/script-reference/unityengine/rect.md) |             |

### Remarks

When creating a new Editor control it is a sound design to implement the actual control without relying on GUILayout and instead have the control take a [Rect](/engine/6000.3/script-reference/unityengine/rect.md) as parameter, similar to the controls in the [EditorGUI](/engine/6000.3/script-reference/unityeditor/editorgui.md) class. This ensures the control can also be used in for example a [PropertyDrawer](/engine/6000.3/script-reference/unityeditor/propertydrawer.md), which does not allow GUILayout.

Once a non-layout version of the control is implemented, a layout version can easily be made as well, which simply calls into the non-layout version. In order to get a rect fitting for the control, the GetControlRect function can be used.

## GetControlRect(bool, float, GUILayoutOption\[])

Get a rect for an Editor control.

```csharp
public static Rect GetControlRect(bool hasLabel, float height, params GUILayoutOption[] options)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Optional boolean to specify if the control has a label. Default is true.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The height in pixels of the control. Default is [EditorGUIUtility.singleLineHeight](/engine/6000.3/script-reference/unityeditor/editorguiutility/singlelineheight.md).**** (\[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`. 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 |
| ----------------------------------------------------------- | ----------- |
| [Rect](/engine/6000.3/script-reference/unityengine/rect.md) |             |

### Remarks

When creating a new Editor control it is a sound design to implement the actual control without relying on GUILayout and instead have the control take a [Rect](/engine/6000.3/script-reference/unityengine/rect.md) as parameter, similar to the controls in the [EditorGUI](/engine/6000.3/script-reference/unityeditor/editorgui.md) class. This ensures the control can also be used in for example a [PropertyDrawer](/engine/6000.3/script-reference/unityeditor/propertydrawer.md), which does not allow GUILayout.

Once a non-layout version of the control is implemented, a layout version can easily be made as well, which simply calls into the non-layout version. In order to get a rect fitting for the control, the GetControlRect function can be used.

## GetControlRect(bool, float, GUIStyle, GUILayoutOption\[])

Get a rect for an Editor control.

```csharp
public static Rect GetControlRect(bool hasLabel, float height, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Optional boolean to specify if the control has a label. Default is true.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The height in pixels of the control. Default is [EditorGUIUtility.singleLineHeight](/engine/6000.3/script-reference/unityeditor/editorguiutility/singlelineheight.md).**** (\[GUIStyle]\(/engine/6000.3/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.3/script-reference/unityengine/guistyle.md) to use for the control.**** (\[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`. 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 |
| ----------------------------------------------------------- | ----------- |
| [Rect](/engine/6000.3/script-reference/unityengine/rect.md) |             |

### Remarks

When creating a new Editor control it is a sound design to implement the actual control without relying on GUILayout and instead have the control take a [Rect](/engine/6000.3/script-reference/unityengine/rect.md) as parameter, similar to the controls in the [EditorGUI](/engine/6000.3/script-reference/unityeditor/editorgui.md) class. This ensures the control can also be used in for example a [PropertyDrawer](/engine/6000.3/script-reference/unityeditor/propertydrawer.md), which does not allow GUILayout.

Once a non-layout version of the control is implemented, a layout version can easily be made as well, which simply calls into the non-layout version. In order to get a rect fitting for the control, the GetControlRect function can be used.
