# GetScreenRect

> Returns the screen-space axis-aligned bounding box of the given RectTransform.

## Definition

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

## GetScreenRect(RectTransform)

Returns the screen-space axis-aligned bounding box of the given RectTransform.

```csharp
public static Rect GetScreenRect(this RectTransform rectTransform)
```

### Parameters

**** (\[RectTransform]\(/engine/6000.6/script-reference/unityengine/recttransform)): The RectTransform whose screen-space bounding box to compute.

### Returns

| Type                                                        | Description                                                                                                                                                 |
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Rect](/engine/6000.6/script-reference/unityengine/rect.md) | A [Rect](/engine/6000.6/script-reference/unityengine/rect.md) describing the screen-space bounding box in pixels. Width and height are always non-negative. |

### Remarks

The four world-space corners are projected to screen space using [Camera.main](/engine/6000.6/script-reference/unityengine/camera/main.md). For Screen Space - Overlay canvases, the corners are already in screen-pixel coordinates and camera projection is skipped regardless of whether [Camera.main](/engine/6000.6/script-reference/unityengine/camera/main.md) is set, to avoid double-projecting them.

**Note**: This method uses [Camera.main](/engine/6000.6/script-reference/unityengine/camera/main.md) for camera projection. For canvases rendered by a specific non-main camera, use [RectTransformUtility.GetScreenRect](/engine/6000.6/script-reference/unityengine/recttransformutility/getscreenrect.md)(RectTransform,Camera) and pass the correct camera explicitly.

Additional Resources: [RectTransformUtility.GetScreenRect](/engine/6000.6/script-reference/unityengine/recttransformutility/getscreenrect.md)(RectTransform,Camera).

## GetScreenRect(RectTransform, Camera)

Returns the screen-space axis-aligned bounding box of the given RectTransform, using the specified camera for projection.

```csharp
public static Rect GetScreenRect(this RectTransform rectTransform, Camera camera)
```

### Parameters

**** (\[RectTransform]\(/engine/6000.6/script-reference/unityengine/recttransform)): The RectTransform whose screen-space bounding box to compute.**** (\[Camera]\(/engine/6000.6/script-reference/unityengine/camera)): The camera to use for world-to-screen projection. If null, or if the RectTransform belongs to a Screen Space - Overlay canvas, camera projection is skipped and the world corners are used directly as screen coordinates.

### Returns

| Type                                                        | Description                                                                                                                                                 |
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Rect](/engine/6000.6/script-reference/unityengine/rect.md) | A [Rect](/engine/6000.6/script-reference/unityengine/rect.md) describing the screen-space bounding box in pixels. Width and height are always non-negative. |

### Remarks

The four world-space corners are projected to screen space using the provided camera. For Screen Space - Overlay canvases, projection is skipped regardless of the camera argument to avoid double-projecting coordinates that are already in screen space.

Use the no-argument overload [RectTransformUtility.GetScreenRect](/engine/6000.6/script-reference/unityengine/recttransformutility/getscreenrect.md)(RectTransform) to project using [Camera.main](/engine/6000.6/script-reference/unityengine/camera/main.md).

Additional Resources: [RectTransformUtility.GetScreenRect](/engine/6000.6/script-reference/unityengine/recttransformutility/getscreenrect.md)(RectTransform).
