Class TweenRectTransformExtensions
Provides extension methods for animating UnityEngine.RectTransform components using the Scylla tween system.
Covers the anchored position (2D and 3D, with per-axis X/Y overloads), size delta (with dedicated width and height overloads), pivot, anchor minimum, and anchor maximum.
All methods operate on the RectTransform's layout properties and are designed for
use with Unity UI (UGUI) elements positioned within a Canvas. All methods return a
pre-configured tween instance sourced from TweenPool. The tween is not
started automatically - call Play() or
PlayManaged(ITween) on the returned instance to begin playback. The
start value is captured lazily from the UnityEngine.RectTransform at the moment playback
begins, unless you override it with a SetFrom call before playing.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenRectTransformExtensions
Methods
TweenAnchorMax(RectTransform, Vector2, float)
Creates a tween that animates the UnityEngine.RectTransform.anchorMax of a rect transform
from its current value to endValue over the specified duration.
The anchor maximum is the normalized position (each component in [0, 1]) within the parent rect that defines the upper-right corner of the anchor region. When anchor max equals anchor min, the element uses a fixed-size layout; when they differ, the element stretches to fill the anchor region.
Animating anchors is an advanced technique that changes the element's layout relationship to its parent. In most cases, animating TweenAnchoredPosition(RectTransform, Vector2, float) or TweenSizeDelta(RectTransform, Vector2, float) is more predictable for simple movement and resizing.
Declaration
public static TweenVector2 TweenAnchorMax(this RectTransform rectTransform, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose anchor maximum will be animated. Must not be |
| Vector2 | endValue | The target anchor maximum as a normalized UnityEngine.Vector2. Each component should be in the range [0, 1]. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenAnchorMin(RectTransform, Vector2, float)
Creates a tween that animates the UnityEngine.RectTransform.anchorMin of a rect transform
from its current value to endValue over the specified duration.
The anchor minimum is the normalized position (each component in [0, 1]) within the parent rect that defines the lower-left corner of the anchor region. When anchor min equals anchor max, the element uses a fixed-size layout; when they differ, the element stretches to fill the anchor region.
Animating anchors is an advanced technique that changes the element's layout relationship to its parent. In most cases, animating TweenAnchoredPosition(RectTransform, Vector2, float) or TweenSizeDelta(RectTransform, Vector2, float) is more predictable for simple movement and resizing.
Declaration
public static TweenVector2 TweenAnchorMin(this RectTransform rectTransform, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose anchor minimum will be animated. Must not be |
| Vector2 | endValue | The target anchor minimum as a normalized UnityEngine.Vector2. Each component should be in the range [0, 1]. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenAnchoredPosition(RectTransform, Vector2, float)
Creates a tween that animates the UnityEngine.RectTransform.anchoredPosition of a rect
transform from its current value to endValue over the specified duration.
Anchored position is the 2D position of the pivot point relative to the anchor reference point, measured in canvas pixels. This is the standard way to move UGUI elements programmatically without breaking their layout anchor configuration.
Declaration
public static TweenVector2 TweenAnchoredPosition(this RectTransform rectTransform, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose anchored position will be animated. Must not be |
| Vector2 | endValue | The target anchored position as a UnityEngine.Vector2 in canvas pixels, relative to the anchor reference point. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenAnchoredPosition3D(RectTransform, Vector3, float)
Creates a tween that animates the UnityEngine.RectTransform.anchoredPosition3D of a rect
transform from its current value to endValue over the specified duration.
Anchored position 3D extends UnityEngine.RectTransform.anchoredPosition with a Z component, which controls the depth offset of the element relative to its anchor. This is useful when UGUI elements are placed in world-space canvases or when depth layering is required.
Declaration
public static TweenVector3 TweenAnchoredPosition3D(this RectTransform rectTransform, Vector3 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose 3D anchored position will be animated. Must not be |
| Vector3 | endValue | The target 3D anchored position as a UnityEngine.Vector3 in canvas units (X, Y in canvas pixels; Z as depth offset). |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector3 | A TweenVector3 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenAnchoredPositionX(RectTransform, float, float)
Creates a tween that animates only the X component of the UnityEngine.RectTransform.anchoredPosition, leaving the Y component unchanged.
Useful for horizontal slide-in or slide-out animations without affecting the vertical layout position.
Declaration
public static TweenFloat TweenAnchoredPositionX(this RectTransform rectTransform, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose anchored X position will be animated. Must not be |
| float | endValue | The target X coordinate of the anchored position in canvas pixels. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenAnchoredPositionY(RectTransform, float, float)
Creates a tween that animates only the Y component of the UnityEngine.RectTransform.anchoredPosition, leaving the X component unchanged.
Useful for vertical slide-in or slide-out animations without affecting the horizontal layout position.
Declaration
public static TweenFloat TweenAnchoredPositionY(this RectTransform rectTransform, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose anchored Y position will be animated. Must not be |
| float | endValue | The target Y coordinate of the anchored position in canvas pixels. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenHeight(RectTransform, float, float)
Creates a tween that animates only the Y component of the UnityEngine.RectTransform.sizeDelta (the height), leaving the X component unchanged.
For non-stretched elements this directly controls the element's rendered height in canvas pixels. For stretched elements the meaning depends on the anchor configuration.
Declaration
public static TweenFloat TweenHeight(this RectTransform rectTransform, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose height (sizeDelta.y) will be animated. Must not be |
| float | endValue | The target height in canvas pixels (sizeDelta.y). |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenPivot(RectTransform, Vector2, float)
Creates a tween that animates the UnityEngine.RectTransform.pivot of a rect transform from
its current value to endValue over the specified duration.
The pivot is a normalized point (each component in [0, 1]) that defines the origin of
rotation and scaling, and the reference point for anchored position. (0.5, 0.5) is
the center, (0, 0) is the bottom-left corner, and (1, 1) is the top-right
corner. Animating the pivot can produce interesting asymmetric scaling and rotation effects.
Changing the pivot does not move the element visually unless the anchored position is adjusted accordingly. Unity adjusts UnityEngine.RectTransform.anchoredPosition automatically when the pivot is set through the Inspector; this tween bypasses that compensation.
Declaration
public static TweenVector2 TweenPivot(this RectTransform rectTransform, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose pivot will be animated. Must not be |
| Vector2 | endValue | The target pivot as a normalized UnityEngine.Vector2. Each component should be in the range [0, 1]. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenSizeDelta(RectTransform, Vector2, float)
Creates a tween that animates the UnityEngine.RectTransform.sizeDelta of a rect transform
from its current value to endValue over the specified duration.
Size delta is the difference between the rect transform's size and its parent's size (scaled by the difference between anchor max and anchor min). For non-stretched elements (where anchor min equals anchor max), size delta directly represents the element's width and height in canvas pixels. Use TweenWidth(RectTransform, float, float) or TweenHeight(RectTransform, float, float) to animate only one dimension.
Declaration
public static TweenVector2 TweenSizeDelta(this RectTransform rectTransform, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose size delta will be animated. Must not be |
| Vector2 | endValue | The target size delta as a UnityEngine.Vector2 (X = width delta, Y = height delta) in canvas pixels. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenWidth(RectTransform, float, float)
Creates a tween that animates only the X component of the UnityEngine.RectTransform.sizeDelta (the width), leaving the Y component unchanged.
For non-stretched elements this directly controls the element's rendered width in canvas pixels. For stretched elements the meaning depends on the anchor configuration.
Declaration
public static TweenFloat TweenWidth(this RectTransform rectTransform, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | rectTransform | The rect transform whose width (sizeDelta.x) will be animated. Must not be |
| float | endValue | The target width in canvas pixels (sizeDelta.x). |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |