# AlignRectToDevice

> Align a local space rectangle to the pixel grid.

## Definition

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

## AlignRectToDevice(Rect, int, int)

Align a local space rectangle to the pixel grid.

```csharp
public static Rect AlignRectToDevice(Rect rect, out int widthInPixels, out int heightInPixels)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Width, in pixel units, of the axis-aligned bounding box that encompasses the aligned points.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Height, in pixel units, of the axis-aligned bounding box that encompasses the aligned points.

### Returns

| Type                                                        | Description                           |
| ----------------------------------------------------------- | ------------------------------------- |
| [Rect](/engine/6000.0/script-reference/unityengine/rect.md) | The aligned rectangle in local space. |

### Remarks

Aligns the top-left and bottom-right corners of the provided local space rectangle to the pixel grid and returns the local space axis-aligned bounding box that encompasses those points.

## AlignRectToDevice(Rect)

Align a local space rectangle to the pixel grid.

```csharp
public static Rect AlignRectToDevice(Rect rect)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)):&#x20;

### Returns

| Type                                                        | Description                           |
| ----------------------------------------------------------- | ------------------------------------- |
| [Rect](/engine/6000.0/script-reference/unityengine/rect.md) | The aligned rectangle in local space. |

### Remarks

Aligns the top-left and bottom-right corners of the provided local space rectangle to the pixel grid and returns the local space axis-aligned bounding box that encompasses those points.
