Sizing a RectTransform - rmfandyplayz/UnityUIAnimationTools GitHub Wiki

Four step types move or resize a UI element. Pick the one that matches how you're thinking about it:

Type Think of it as Reach for it when
Anchored Position Where it sits. Size stays the same. Sliding something in or out
Size Delta How big it is, growing out from its pivot A panel that expands, a bar that grows
Offset Min Where its left and bottom edges are Pulling one side in or out
Offset Max Where its right and top edges are Pulling one side in or out

All four take X and Y (Z is ignored) and support Snapping.

Plus means right and up

In every one of these steps, a positive number means right (for X) or up (for Y).

That matches the Inspector's Left and Bottom fields, but not Right and Top. Unity shows those two with the sign flipped, so that a positive number there always means "pushed inwards".

So a panel inset 12 pixels on every side reads Left 12, Bottom 12, Right 12, Top 12 in the Inspector, but in a step it's:

  • Offset Min (12, 12)
  • Offset Max (-12, -12)

Tip

Copying a Right or Top value from the Inspector into a step? Flip its sign.

Don't mix whole-box and edge steps

Anchored Position and Size Delta move the whole box. Offset Min and Offset Max move one corner and hold the other still. So modify either AnchorPos/SizeDelta or OffsetMin/Max unless you want to see them undo each other every frame.

For example: slide a panel 100 pixels right with Anchored Position, while an Offset Min step holds its left edge. The slide moves both edges, the Offset Min step drags the left edge back, and the panel ends up stretching to the right instead of moving.

Two from the same group are fine together: sliding while growing, or moving both corners.

Size Delta on a stretched element

If the element's anchors are spread apart (it stretches with its parent), Size Delta isn't a size in pixels. It's how much bigger than the anchored area the element is:

  • (0, 0) exactly fills it.
  • (-24, -24) is 12 pixels smaller all round.

If you want a literal pixel size, un-stretch the anchors first.

Under the hood
  • A RectTransform really stores anchoredPosition and sizeDelta (plus anchors and pivot). offsetMin and offsetMax are worked out from those. Setting offsetMin changes both sizeDelta and anchoredPosition so that offsetMax stays where it was, and the other way round. That's why the two groups fight and the members of one group don't.
  • Measured on a 100×40 rect: setting offsetMin from (-50, -20) to (-10, -10) also moved sizeDelta to (60, 30) and anchoredPosition to (20, 5).
  • The Inspector's Right and Top fields are -offsetMax.x and -offsetMax.y.
⚠️ **GitHub.com Fallback** ⚠️