# Rect

> Creates a new rectangle.

## Definition

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

## Rect(float, float, float, float)

Creates a new rectangle.

```csharp
public Rect(float x, float y, float width, float height)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The X value the rect is measured from.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The Y value the rect is measured from.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The width of the rectangle.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The height of the rectangle.

### Remarks

```csharp
using UnityEngine;

public class RectExample : MonoBehaviour
{
    void Start()
    {
        Rect rect = new Rect(0, 0, 10, 10);

        // prints: (x:0, y:0, width:10, height:10)
        Debug.Log(rect);
    }
}
```

Note: Rect represents an abstract rectangle, and can be used in a variety of situations. As such, Rects don't have an explicit top, bottom, left or right. For example, Y values in Camera space are measured from the bottom of the screen, but Y values in Editor GUI space are measured from the top of the window, therefore whether the Y value of a Rect is its "top" or "bottom" will vary depending on where you use the Rect value. You can refer to the corners by using [Rect.min](/engine/6000.6/script-reference/unityengine/rect/min.md) and [Rect.max](/engine/6000.6/script-reference/unityengine/rect/max.md).

## Rect(Vector2, Vector2)

Creates a rectangle given a size and position.

```csharp
public Rect(Vector2 position, Vector2 size)
```

### Parameters

**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The position of the minimum corner of the rect.**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The width and height of the rect.

### Remarks

This form of the constructor is convenient when you are already working with Vector2 values.

## Rect(Vector2, Vector2)

Creates a rectangle given a size and position.

```csharp
public Rect(in Vector2 position, in Vector2 size)
```

### Parameters

**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The position of the minimum corner of the rect.**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The width and height of the rect.

### Remarks

This form of the constructor is convenient when you are already working with Vector2 values.
