Menu
Lumberyard
Developer Guide (Version 1.11)

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

Copy
AZ::Vector2 GetCanvasPosition()

GetLocalPosition

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

Syntax

Copy
AZ::Vector2 GetLocalPosition()

GetPivot

Returns the pivot point.

Syntax

Copy
AZ::Vector2 GetPivot()

GetScale

Returns the scale.

Syntax

Copy
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

Copy
bool GetScaleToDevice()

GetViewportPosition

Returns the position for this element in viewport space.

Syntax

Copy
AZ::Vector2 GetViewportPosition()

GetZRotation

Returns the rotation about the z-axis.

Syntax

Copy
float GetZRotation()

MoveCanvasPositionBy

Moves this element in canvas space.

Syntax

Copy
void MoveCanvasPositionBy(const AZ::Vector2& offset)

MoveLocalPositionBy

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

Syntax

Copy
void MoveLocalPositionBy(const AZ::Vector2& offset)

MoveViewportPositionBy

Moves this element in viewport space.

Syntax

Copy
void MoveViewportPositionBy(const AZ::Vector2& offset)

SetCanvasPosition

Sets the position for this element in canvas space.

Syntax

Copy
void SetCanvasPosition(const AZ::Vector2& position)

SetLocalPosition

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

Syntax

Copy
void SetLocalPosition(const AZ::Vector2& position)

SetPivot

Sets the pivot point.

Syntax

Copy
void SetPivot(AZ::Vector2 pivot)

SetScale

Sets the scale.

Syntax

Copy
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

Copy
void SetScaleToDevice(bool scaleToDevice)

SetViewportPosition

Sets the position for this element in viewport space.

Syntax

Copy
void SetViewportPosition(const AZ::Vector2& position)

SetZRotation

Sets the rotation about the z-axis.

Syntax

Copy
void SetZRotation(float rotation)

UiTransform2dBus

Services anchors and offsets for the UITransform2dComponent.

GetAnchors

Returns the UI anchors.

Syntax

Copy
UiAnchors GetAnchors()

Following are possible values for UiAnchors.

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

GetOffsets

Returns the UI offsets.

Syntax

Copy
UiOffsets GetOffsets()

Following are possible values for UiOffsets.

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

SetAnchors

Sets the anchors.

Syntax

Copy
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

Copy
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

Copy
void SetPivotAndAdjustOffsets(AZ::Vector2 pivot)