# RectInt

> A 2D Rectangle defined by x, y, width, height with integers.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<RectInt>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IFormattable](https://learn.microsoft.com/dotnet/api/system.iformattable)

```csharp
public struct RectInt : IEquatable<RectInt>, IFormattable
```

## Constructors

| Constructor                                                                                                                                              | Description            |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| [RectInt(System.Int32,System.Int32,System.Int32,System.Int32)](/engine/6000.7/script-reference/unityengine/rectint/ctor.md#rectint\(int-int-int-int\))   | Creates a new RectInt. |
| [RectInt(UnityEngine.Vector2Int,UnityEngine.Vector2Int)](/engine/6000.7/script-reference/unityengine/rectint/ctor.md#rectint\(vector2int-vector2int\))   | Creates a new RectInt. |
| [RectInt(UnityEngine.Vector2Int@,UnityEngine.Vector2Int@)](/engine/6000.7/script-reference/unityengine/rectint/ctor.md#rectint\(vector2int-vector2int\)) | Creates a new RectInt. |

## Properties

| Property                                                                                        | Description                                                                                                                                       |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| [allPositionsWithin](/engine/6000.7/script-reference/unityengine/rectint/allpositionswithin.md) | A PositionCollection that contains all positions within the [RectInt](/engine/6000.7/script-reference/unityengine/rectint.md).                    |
| [center](/engine/6000.7/script-reference/unityengine/rectint/center.md)                         | Center coordinate of the rectangle.                                                                                                               |
| [height](/engine/6000.7/script-reference/unityengine/rectint/height.md)                         | Height of the rectangle.                                                                                                                          |
| [max](/engine/6000.7/script-reference/unityengine/rectint/max.md)                               | The upper right corner of the rectangle; which is the maximal position of the rectangle along the x- and y-axes, when it is aligned to both axes. |
| [min](/engine/6000.7/script-reference/unityengine/rectint/min.md)                               | The lower left corner of the rectangle; which is the minimal position of the rectangle along the x- and y-axes, when it is aligned to both axes.  |
| [position](/engine/6000.7/script-reference/unityengine/rectint/position.md)                     | Returns the position (x, y) of the `RectInt`.                                                                                                     |
| [size](/engine/6000.7/script-reference/unityengine/rectint/size.md)                             | Returns the width and height of the `RectInt`.                                                                                                    |
| [width](/engine/6000.7/script-reference/unityengine/rectint/width.md)                           | Width of the rectangle.                                                                                                                           |
| [x](/engine/6000.7/script-reference/unityengine/rectint/x.md)                                   | Left coordinate of the rectangle.                                                                                                                 |
| [xMax](/engine/6000.7/script-reference/unityengine/rectint/xmax.md)                             | Shows the maximum X value of the `RectInt`.                                                                                                       |
| [xMin](/engine/6000.7/script-reference/unityengine/rectint/xmin.md)                             | Shows the minimum X value of the `RectInt`.                                                                                                       |
| [y](/engine/6000.7/script-reference/unityengine/rectint/y.md)                                   | Top coordinate of the rectangle.                                                                                                                  |
| [yMax](/engine/6000.7/script-reference/unityengine/rectint/ymax.md)                             | Shows the maximum Y value of the `RectInt`.                                                                                                       |
| [yMin](/engine/6000.7/script-reference/unityengine/rectint/ymin.md)                             | Show the minimum Y value of the `RectInt`.                                                                                                        |

## Static Properties

| Property                                                            | Description                                   |
| ------------------------------------------------------------------- | --------------------------------------------- |
| [zero](/engine/6000.7/script-reference/unityengine/rectint/zero.md) | Shorthand for writing `new RectInt(0,0,0,0)`. |

## Methods

| Method                                                                                | Description                                                                                                                          |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| [ClampToBounds](/engine/6000.7/script-reference/unityengine/rectint/clamptobounds.md) | Clamps the position and size of the `RectInt` to the given bounds.                                                                   |
| [Contains](/engine/6000.7/script-reference/unityengine/rectint/contains.md)           | Returns true if the given position is within the [RectInt](/engine/6000.7/script-reference/unityengine/rectint.md).                  |
| [Equals](/engine/6000.7/script-reference/unityengine/rectint/equals.md)               | Returns true if the given RectInt is equal to this RectInt.                                                                          |
| [Overlaps](/engine/6000.7/script-reference/unityengine/rectint/overlaps.md)           | RectInts overlap if each RectInt [RectInt.Contains](/engine/6000.7/script-reference/unityengine/rectint/contains.md) a shared point. |
| [SetMinMax](/engine/6000.7/script-reference/unityengine/rectint/setminmax.md)         | Sets the bounds to the `min` and `max` value of the rect.                                                                            |
| [ToString](/engine/6000.7/script-reference/unityengine/rectint/tostring.md)           | Returns the x, y, width and height of the `RectInt`.                                                                                 |

## Operators

| Operator                                                                          | Description                                  |
| --------------------------------------------------------------------------------- | -------------------------------------------- |
| [operator ==](/engine/6000.7/script-reference/unityengine/rectint/op-equality.md) | Returns true if the rectangles are the same. |

## Structs

| Struct                                                                                                  | Description                                                                                                                             |
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| [RectInt.PositionEnumerator](/engine/6000.7/script-reference/unityengine/rectint/positionenumerator.md) | An iterator that allows you to iterate over all positions within the [RectInt](/engine/6000.7/script-reference/unityengine/rectint.md). |
