Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
A 2D Rectangle defined by x, y position and width, height.
Rect structure is mainly used for 2D operations. The UnityGUI system uses it extensively
and it is also to set the onscreen position of a Camera's view.
yvalues are assumed to be used along with
height. This means that if you change
heightthen the rectangle will change position but stay the same size. On the other hand, if you change the values of
yMaxthen the rectangle will change size and the top-left corner will also change.See Also: GUI Scripting Guide, Camera.rect, Camera.pixelRect.
|center||Center coordinate of the rectangle.|
|height||Height of the rectangle.|
|max||Upper right corner of the rectangle.|
|min||Lower left corner of the rectangle.|
|position||The top left coordinates of the rectangle.|
|size||The size of the rectangle.|
|width||Width of the rectangle.|
|x||Left coordinate of the rectangle.|
|xMax||Right coordinate of the rectangle.|
|xMin||Left coordinate of the rectangle.|
|y||Top coordinate of the rectangle.|
|yMax||Bottom coordinate of the rectangle.|
|yMin||Top coordinate of the rectangle.|
|Rect||Creates a new rectangle.|
|Contains||Returns true if the x and y components of point is a point inside this rectangle. If allowInverse is present and true, the width and height of the Rect are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.|
|Overlaps||Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.|
|Set||Set components of an existing Rect.|
|ToString||Returns a nicely formatted string for this Rect.|
|MinMaxRect||Creates a rectangle from min/max coordinate values.|
|NormalizedToPoint||Returns a point inside a rectangle, given normalized coordinates.|
|PointToNormalized||Returns the normalized coordinates cooresponding the the point.|