Variable: UiAnchor
constUiAnchor:object
Defined in: ui/types/ui-anchor.ts:101
Common anchor/pivot presets for RectTransformEcsComponent, expressing
the "pin to corner/edge/center" and "stretch" cases resolveRect supports
without hand writing x/y axis descriptors. Each preset is a factory -
call it with the size/margin values that actually apply to its axes
(a point-anchored axis takes a literal size, a stretch-anchored axis
takes a margin - never both for the same axis) and spread the result into
addRectTransformComponent's options, e.g.
addRectTransformComponent(world, entity, UiAnchor.topLeft({ x: 200, y: 60 })).
Type Declaration
bottomCenter
bottomCenter: (
size) =>UiAnchorConfig
Pins to the parent's bottom edge, horizontally centered. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
bottomLeft
bottomLeft: (
size) =>UiAnchorConfig
Pins to the parent's bottom-left corner. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
bottomRight
bottomRight: (
size) =>UiAnchorConfig
Pins to the parent's bottom-right corner. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
center
center: (
size) =>UiAnchorConfig
Centers within the parent's rect. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
middleLeft
middleLeft: (
size) =>UiAnchorConfig
Pins to the parent's left edge, vertically centered. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
middleRight
middleRight: (
size) =>UiAnchorConfig
Pins to the parent's right edge, vertically centered. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
stretchAll
stretchAll: (
margin) =>UiAnchorConfig
Stretches to fill the parent's full rect. A TextEcsComponent child
anchored this way centers/right-aligns/justifies correctly despite the
center pivot: createUiLayoutEcsSystem syncs both maxWidth and
horizontalAlignPivot from this rect every frame for any stretch-x
anchor, not just left-pivoted ones (see its own doc comment).
margin is added to both axes' anchored span. Defaults to {x: 0, y: 0}.
Parameters
margin?
Vector2 = defaultStretchMargin
Returns
stretchBottom
stretchBottom: (
__namedParameters) =>UiAnchorConfig
A full-width horizontal band pinned to the parent's bottom edge - the
common "HUD bottom bar" anchor. height sets the band's height.
Parameters
__namedParameters
Returns
stretchHorizontal
stretchHorizontal: (
__namedParameters) =>UiAnchorConfig
Stretches to fill the parent's full width, vertically centered.
Parameters
__namedParameters
Returns
stretchHorizontalLeft
stretchHorizontalLeft: (
__namedParameters) =>UiAnchorConfig
Stretches to fill the parent's full width, vertically centered, with
its pivot on the left edge rather than the center - unlike
stretchHorizontal. A TextEcsComponent child centers/right-aligns/
justifies correctly under either preset - createUiLayoutEcsSystem
syncs horizontalAlignPivot from whichever pivot the anchor uses, not
just a left one (see its own doc comment) - so reach for this preset
when you specifically want the rect's own local origin (e.g. for
manual position math, or a non-text child) on the left edge rather
than the center; it's no longer required just to make text alignment
work.
Parameters
__namedParameters
Returns
stretchLeft
stretchLeft: (
__namedParameters) =>UiAnchorConfig
A full-height vertical band pinned to the parent's left edge - the
common "side panel" anchor. width sets the band's width.
Parameters
__namedParameters
Returns
stretchRight
stretchRight: (
__namedParameters) =>UiAnchorConfig
A full-height vertical band pinned to the parent's right edge.
width sets the band's width.
Parameters
__namedParameters
Returns
stretchTop
stretchTop: (
__namedParameters) =>UiAnchorConfig
A full-width horizontal band pinned to the parent's top edge - the
common "HUD top bar" anchor. height sets the band's height (it's
point-anchored vertically); horizontalMargin is a horizontal margin.
Parameters
__namedParameters
Returns
stretchTopLeft
stretchTopLeft: (
__namedParameters) =>UiAnchorConfig
A full-width horizontal band pinned to the parent's top edge, like
stretchTop, but with its pivot on the left edge rather than the
center - see stretchHorizontalLeft's own doc comment for what that's
useful for. height still sets the band's height (point-anchored
vertically); horizontalMargin is still a horizontal margin.
Parameters
__namedParameters
Returns
stretchTopRight
stretchTopRight: (
__namedParameters) =>UiAnchorConfig
The mirror image of stretchTopLeft - a full-width horizontal band
pinned to the parent's top edge, with its pivot on the right edge
rather than the left or center. Useful for the same reasons
stretchHorizontalLeft/stretchTopLeft are (manual position math, or a
non-text child, anchored from the right edge instead) - not for
horizontalAlign, which works under any pivot on a stretch-x anchor
(see createUiLayoutEcsSystem's own doc comment on horizontalAlignPivot
syncing). height still sets the band's height (point-anchored
vertically); horizontalMargin is still a horizontal margin.
Parameters
__namedParameters
Returns
stretchVertical
stretchVertical: (
__namedParameters) =>UiAnchorConfig
Stretches to fill the parent's full height, horizontally centered.
Parameters
__namedParameters
Returns
topCenter
topCenter: (
size) =>UiAnchorConfig
Pins to the parent's top edge, horizontally centered. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
topLeft
topLeft: (
size) =>UiAnchorConfig
Pins to the parent's top-left corner. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize
Returns
topRight
topRight: (
size) =>UiAnchorConfig
Pins to the parent's top-right corner. size sets the element's literal width/height.
Parameters
size?
Vector2 = defaultPointSize