# GetAspectRect

> Reserve layout space for a rectangle with a specific aspect ratio.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.IMGUIModule

## GetAspectRect(float)

Reserve layout space for a rectangle with a specific aspect ratio.

```csharp
public static Rect GetAspectRect(float aspect)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The aspect ratio of the element (width / height).

### Returns

| Type                                                        | Description               |
| ----------------------------------------------------------- | ------------------------- |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The rect for the control. |

### Remarks

Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md)

## GetAspectRect(float, GUIStyle)

Reserve layout space for a rectangle with a specific aspect ratio.

```csharp
public static Rect GetAspectRect(float aspect, GUIStyle style)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The aspect ratio of the element (width / height).**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): An optional style. If specified, the style's `padding` value will be added to the sizes of the returned rectangle & the style's `margin` values will be used for spacing.

### Returns

| Type                                                        | Description               |
| ----------------------------------------------------------- | ------------------------- |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The rect for the control. |

### Remarks

Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md)

## GetAspectRect(float, GUILayoutOption\[])

Reserve layout space for a rectangle with a specific aspect ratio.

```csharp
public static Rect GetAspectRect(float aspect, params GUILayoutOption[] options)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The aspect ratio of the element (width / height).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md)

### Returns

| Type                                                        | Description               |
| ----------------------------------------------------------- | ------------------------- |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The rect for the control. |

### Remarks

Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md)

## GetAspectRect(float, GUIStyle, GUILayoutOption\[])

Reserve layout space for a rectangle with a specific aspect ratio.

```csharp
public static Rect GetAspectRect(float aspect, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The aspect ratio of the element (width / height).**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): An optional style. If specified, the style's `padding` value will be added to the sizes of the returned rectangle & the style's `margin` values will be used for spacing.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md)

### Returns

| Type                                                        | Description               |
| ----------------------------------------------------------- | ------------------------- |
| [Rect](/engine/6000.7/script-reference/unityengine/rect.md) | The rect for the control. |

### Remarks

Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md)
