Lumberyard
User Guide (Version 1.16)

UITransform2dComponent

Controls positioning, scaling, rotation, anchor, and offset settings for UI elements.

UiTransformBus

Services messages for the UiTransform2dComponent.

GetCanvasPosition

Returns the position for this element in canvas space.

Syntax

AZ::Vector2 GetCanvasPosition()

GetLocalPosition

Returns the position for this element relative to the center of the element's anchors.

Syntax

AZ::Vector2 GetLocalPosition()

GetPivot

Returns the pivot point.

Syntax

AZ::Vector2 GetPivot()

GetScale

Returns the scale.

Syntax

AZ::Vector2 GetScale()

GetScaleToDevice

Returns whether this element and all its children are scaled to allow for the difference between the authored canvas size and the actual viewport size.

Syntax

bool GetScaleToDevice()

GetViewportPosition

Returns the position for this element in viewport space.

Syntax

AZ::Vector2 GetViewportPosition()

GetZRotation

Returns the rotation about the z-axis.

Syntax

float GetZRotation()

MoveCanvasPositionBy

Moves this element in canvas space.

Syntax

void MoveCanvasPositionBy(const AZ::Vector2& offset)

MoveLocalPositionBy

Moves this element relative to the center of the element's anchors.

Syntax

void MoveLocalPositionBy(const AZ::Vector2& offset)

MoveViewportPositionBy

Moves this element in viewport space.

Syntax

void MoveViewportPositionBy(const AZ::Vector2& offset)

SetCanvasPosition

Sets the position for this element in canvas space.

Syntax

void SetCanvasPosition(const AZ::Vector2& position)

SetLocalPosition

Sets the position for this element relative to the center of the element's anchors.

Syntax

void SetLocalPosition(const AZ::Vector2& position)

SetPivot

Sets the pivot point.

Syntax

void SetPivot(AZ::Vector2 pivot)

SetScale

Sets the scale.

Syntax

void SetScale(AZ::Vector2 scale)

SetScaleToDevice

Sets whether the element and all its children are scaled to allow for the difference between the authored canvas size and the actual viewport size.

Syntax

void SetScaleToDevice(bool scaleToDevice)

SetViewportPosition

Sets the position for this element in viewport space.

Syntax

void SetViewportPosition(const AZ::Vector2& position)

SetZRotation

Sets the rotation about the z-axis.

Syntax

void SetZRotation(float rotation)

UiTransform2dBus

Services anchors and offsets for the UITransform2dComponent.

GetAnchors

Returns the UI anchors.

Syntax

UiAnchors GetAnchors()

Following are possible values for UiAnchors.

class UiAnchors { float left; float top; float right; float bottom; };

GetOffsets

Returns the UI offsets.

Syntax

UiOffsets GetOffsets()

Following are possible values for UiOffsets.

class UiOffsets { float left; float top; float right; float bottom; };

SetAnchors

Sets the anchors.

Syntax

void SetAnchors(UiAnchors anchors, bool adjustOffsets, bool allowPush)

For possible values for UiAnchors, see GetAnchors.

Parameter Description
adjustOffsets If true, the offsets are adjusted to keep the rectangle in the same position.
allowPush Only takes effect if the anchors are invalid. If true, when an anchor is changed to overlap the anchor opposite it, the opposite anchor moves.

SetOffsets

Sets UI offsets.

Syntax

void SetOffsets(UiOffsets offsets)

For possible values for UiOffsets, see GetOffsets.

SetPivotAndAdjustOffsets

Sets the pivot and adjusts the offsets so that this element stays in the same place.

Syntax

void SetPivotAndAdjustOffsets(AZ::Vector2 pivot)