Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RectTransform

Position, size, anchor and pivot information for a rectangle.
Read time 12 minutesLast updated 4 days ago

Definition

public sealed class RectTransform : Transform, IEnumerable

Remarks

RectTransforms are used for GUI but can also be used for other things. It's used to store and manipulate the position, size, and anchoring of a rectangle and supports various forms of scaling based on a parent RectTransform.
Note: The Inspector changes which properties are exposed based on which anchor preset is in use. For more information see Rect Transform and Basic Layout.

Properties

Property

Description

anchoredPositionThe position of the pivot of this RectTransform relative to the anchor reference point.
anchoredPosition3DThe 3D position of the pivot of this RectTransform relative to the anchor reference point.
anchorMaxThe normalized position in the parent RectTransform that the upper right corner is anchored to.
anchorMinThe normalized position in the parent RectTransform that the lower left corner is anchored to.
drivenByObjectThe object that is driving the values of this RectTransform. Value is null if not driven.
offsetMaxThe offset of the upper right corner of the rectangle relative to the upper right anchor.
offsetMinThe offset of the lower left corner of the rectangle relative to the lower left anchor.
pivotThe normalized position in this RectTransform that it rotates around.
rectThe calculated rectangle in the local space of the Transform.
sendChildDimensionsChangeWhether the RectTransform notifies components when a child RectTransform changes dimensions.
sizeDeltaThe size of this RectTransform relative to the distances between the anchors.

Methods

Method

Description

ForceUpdateRectTransformsForce the recalculation of RectTransforms internal data.
GetLocalCornersGet the corners of the calculated rectangle in the local space of its Transform.
GetWorldCornersGet the corners of the calculated rectangle in world space.
SetInsetAndSizeFromParentEdgeSet the distance of this rectangle relative to a specified edge of the parent rectangle, while also setting its size.
SetSizeWithCurrentAnchorsMakes the RectTransform calculated rect be a given size on the specified axis.

Static Events

Member

Description

reapplyDrivenPropertiesEvent that is invoked for RectTransforms that need to have their driven properties reapplied.

Enums

Enum

Description

RectTransform.AxisEnum to specify an axis, which can be either horizontal or vertical.
RectTransform.EdgeEnum used to specify one edge of a rectangle.

Delegates

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.