SRectTransform
On this classSetParent
| Function | SetParent | Set the parent of the transform. |
| Function | SetInsetAndSizeFromParentEdge | Set the distance of this rectangle relative to a specified edge of the parent rectangle, while also setting its size. |
| Function | SetSizeWithCurrentAnchors | Makes the RectTransform calculated rect be a given size on the specified axis. |
| Property | Rect | – |
| Property | anchorMin | The normalized position in the parent RectTransform that the lower left corner is anchored to. |
| Property | anchorMax | – |
| Property | anchoredPosition3D | – |
| Property | anchoredPosition | – |
| Property | sizeDelta | The size of this RectTransform relative to the distances between the anchors. |
| Property | pivot | The normalized position in this RectTransform that it rotates around. |
| Property | offsetMin | The offset of the lower left corner of the rectangle relative to the lower left anchor. |
| Property | offsetMax | The offset of the upper right corner of the rectangle relative to the upper right anchor. |
| Property | GameObject | – |
Functions
SetParent
Set the parent of the transform.
Parameters
| Name | Type | Default |
|---|---|---|
| parent | SGameObject | – |
| worldPositionStays | bool | – |
Returns
void
Example
Space.Host.ExecutingObject.RectTransform.SetParent(anotherGameObject)
SetInsetAndSizeFromParentEdge
Set the distance of this rectangle relative to a specified edge of the parent rectangle, while also setting its size.
Parameters
| Name | Type | Default |
|---|---|---|
| edge | int | – |
| inset | float | – |
| size | float | – |
Returns
void
Example
Space.Host.ExecutingObject.RectTransform.SetInsetAndSizeFromParentEdge(2, 3.0, 10.0)
SetSizeWithCurrentAnchors
Makes the RectTransform calculated rect be a given size on the specified axis.
Parameters
| Name | Type | Default |
|---|---|---|
| vertical | bool | – |
| size | float | – |
Returns
void
Example
Space.Host.ExecutingObject.RectTransform.SetSizeWithCurrentAnchors(true, 10.0)
Properties
RectRead only
Example
rect = Space.Host.ExecutingObject.RectTransform.Rect
anchorMin
The normalized position in the parent RectTransform that the lower left corner is anchored to.
Example
Space.Host.ExecutingObject.RectTransform.anchorMin= Vector.New(0.3,0.3,0)
anchorMax
Example
Space.Host.ExecutingObject.RectTransform.anchorMax= Vector.New(0.7,0.6,0)
anchoredPosition3D
Example
Space.Host.ExecutingObject.RectTransform.anchoredPosition3D= Vector.New(0.7,0.6,0)
anchoredPosition
Example
Space.Host.ExecutingObject.RectTransform.anchoredPosition= Vector.New(0.7,0.6,0)
sizeDelta
The size of this RectTransform relative to the distances between the anchors.
Example
Space.Host.ExecutingObject.RectTransform.sizeDelta= Vector.New(90,90,0)
pivot
The normalized position in this RectTransform that it rotates around.
Example
Space.Host.ExecutingObject.RectTransform.pivot= Vector.New(0.4,0.4,0)
offsetMin
The offset of the lower left corner of the rectangle relative to the lower left anchor.
Example
Space.Host.ExecutingObject.RectTransform.offsetMin= Vector.New(-50,-50,0)
offsetMax
The offset of the upper right corner of the rectangle relative to the upper right anchor.
Example
Space.Host.ExecutingObject.RectTransform.offsetMax= Vector.New(50,50,0)
GameObjectRead only
Example
theGameObject = Space.Host.ExecutingObject.RectTransform.GameObject



