Rect Manual     Reference     Scripting  
Scripting > Runtime Classes > Rect
Rect Struct

A 2D Rectangle defined by x, y position and width, height

The Rect structure is mainly used for 2D operations; The UnityGUI system uses it extensively, as well as positioning cameras on-screen.

See Also: GUI Scripting Guide, Camera.rect, Camera.pixelRect.

Variables
x

Left coordinate of the rectangle.

y

Top coordinate of the rectangle.

center

Center coordinate of the rectangle.

width

Width of the rectangle.

height

Height of the rectangle.

xMin

Left coordinate of the rectangle.

yMin

Top coordinate of the rectangle.

xMax

Right coordinate of the rectangle.

yMax

Bottom coordinate of the rectangle.

Constructors
Rect

Creates a new rectangle.

Functions
Set

Set components of an existing Rect.

ToString

Returns a nicely formatted string for this Rect.

Contains

Returns true if the x and y components of point is a point inside this rectangle.

Class Functions
MinMaxRect

Creates a rectangle from min/max coordinate values.

operator !=

Returns true if the rectangles are different.

operator ==

Returns true if the rectangles are the same.