RectInt
public sealed struct RectInt Represents a rectangle but with whole numbers
Constructors
RectInt(Int32 x, Int32 y, Int32 width, Int32 height) Initialize a Rect at given position and with given size.
RectInt(Vector2Int point, Vector2Int size) Initialize a Rect at given position and with given size.
Properties
| Name | Type | Description |
|---|---|---|
Width | Int32 | Width of the rect. |
Height | Int32 | Height of the rect. |
Left | Int32 | Position of rect's left edge relative to its parent, can also be interpreted as its position on the X axis. |
Top | Int32 | Position of rect's top edge relative to its parent, can also be interpreted as its position on the Y axis. |
Right | Int32 | Position of rect's right edge relative to its parent. |
Bottom | Int32 | Position of rect's bottom edge relative to its parent. |
Position | Vector2Int | Position of this rect. |
Center | Vector2 | Center of this rect. |
Size | Vector2Int | Size of this rect. |
WithoutPosition | RectInt | Returns this rect with position set to 0 on both axes. |
BottomLeft | Vector2Int | Position of the bottom left edge of this rect. |
BottomRight | Vector2Int | Position of the bottom right edge of this rect. |
TopRight | Vector2Int | Position of the top right edge of this rect. |
TopLeft | Vector2Int | Position of the top left edge of this rect. |
Methods
Boolean IsInside(RectInt rect, Boolean fullyInside = False) Return true if the passed rect is partially or fully inside this rect.
rect — The passed rect to test. fullyInside — to test if the given rect is completely inside this rect. to test for an intersection. Boolean IsInside(Vector2Int pos) Return true if the passed point is inside this rect.
RectInt Shrink(Int32 left, Int32 top, Int32 right, Int32 bottom) Returns a Rect shrunk in every direction by given values.
RectInt Shrink(Int32 x, Int32 y) Returns a Rect shrunk in every direction by given values on each axis.
RectInt Shrink(Int32 amt) Returns a Rect shrunk in every direction by given amount.
RectInt Grow(Int32 left, Int32 top, Int32 right, Int32 bottom) Returns a Rect grown in every direction by given amounts.
RectInt Grow(Int32 x, Int32 y) Returns a Rect grown in every direction by given values on each axis.
RectInt Grow(Int32 amt) Returns a Rect grown in every direction by given amount.
static RectInt FromPoints(Vector2Int a, Vector2Int b) Create a rect between two points. The order of the points doesn't matter.
Void Add(RectInt r) Expand this Rect to contain the other rect
Void Add(Vector2Int point) Expand this Rect to contain the point
RectInt AddPoint(Vector2Int pos) Returns this rect expanded to include this point