Menu
Lumberyard
Developer Guide (Version 1.11)

UICanvasComponent

Contains buses and notification buses for UI canvas and animation.

UiCanvasBus

Services messages for the UiCanvasComponent.

FindElementByName

Returns the entity ID of the first UI element in this canvas that has the specified name.

Syntax

Copy
AZ::EntityId FindElementByName(const AZStd::string& name)

ForceHoverInteractable

Forces a specified interactive element to receive the hover.

Syntax

Copy
void ForceHoverInteractable(AZ::EntityId entityId)

GetChildElement

Returns the entity ID of the child element that has the specified index.

Syntax

Copy
AZ::EntityId GetChildElement(int index)

GetChildElements

Returns a list of entity IDs of the child elements of the canvas.

Syntax

Copy
AZStd::vector<AZ::EntityId> GetChildElements()

GetDrawOrder

Returns the draw order on the canvas.

Syntax

Copy
int GetDrawOrder()

GetEnabled

Returns the enabled flag of the canvas. True if the canvas is enabled; false otherwise. Enabled canvases are updated and rendered for each frame.

Syntax

Copy
bool GetEnabled()

GetHoverInteractable

Returns the entity ID of the interactive element that has the hover.

Syntax

Copy
AZ::EntityId GetHoverInteractable()

GetIsNavigationSupported

Returns true if the canvas accepts navigation input; false otherwise.

Syntax

Copy
bool GetIsNavigationSupported()

GetIsPixelAligned

Returns true if pixel alignment is enabled for this canvas; false otherwise. If pixel alignment is enabled, then all corners of all elements are rounded to the nearest pixel when they are rendered.

Syntax

Copy
bool GetIsPixelAligned()

GetIsRenderToTexture

Returns true if the canvas is rendered to a texture instead of the full screen; false otherwise.

Syntax

Copy
bool GetIsRenderToTexture()

GetKeepLoadedOnLevelUnload

Returns true if the canvas stays loaded when the level is unloaded; false otherwise.

Syntax

Copy
bool GetKeepLoadedOnLevelUnload()

GetNumChildElements

Returns the number of child elements that the canvas has.

Syntax

Copy
int GetNumChildElements()

GetRenderTargetName

Returns the name of the texture that is created when this canvas is rendered to a texture.

Syntax

Copy
AZStd::string GetRenderTargetName()

GetTooltipDisplayElement

Returns the entity ID of the tooltip element that is to be displayed when the pointer pauses on an interactable element.

Syntax

Copy
AZ::EntityId GetTooltipDisplayElement()

RecomputeChangedLayouts

Tells the layout manager for the canvas to recompute the layout. This happens automatically every frame. Occasionally a script modifies something that affects the layout (such as the reparenting of an element) and tries to query positions in the same frame. In this case you can call RecomputeChangedLayouts to force an immediate recalculation of all layouts on the canvas that have been flagged for recomputing.

Syntax

Copy
void RecomputeChangedLayouts()

SetDrawOrder

Sets the draw order on the canvas.

Syntax

Copy
void SetDrawOrder(int drawOrder)

SetEnabled

Sets whether the canvas is enabled. Enabled canvases are updated and rendered for each frame. Specify true to enable the canvas, false to disable.

Syntax

Copy
void SetEnabled(bool enabled)

SetHoverInteractable

Sets the interactable element on the canvas on which the pointer has been paused.

Note

This action is done automatically, but in unusual situations it can be useful to call this function from a script.

Syntax

Copy
void SetHoverInteractable(AZ::EntityId entityId)

SetIsNavigationSupported

Specify true to make the canvas accept navigation input; false otherwise.

Syntax

Copy
void SetIsNavigationSupported(bool isSupported)

SetIsPixelAligned

Specify true to enable pixel alignment for this canvas; false otherwise.

Syntax

Copy
void SetIsPixelAligned(bool isPixelAligned)

SetIsRenderToTexture

Sets whether the canvas is rendered to a texture instead of the full screen. Specify true to render the canvas to a texture; false otherwise.

Syntax

Copy
void SetIsRenderToTexture(bool isRenderToTexture)

SetKeepLoadedOnLevelUnload

Sets whether the canvas stays loaded when the level is unloaded. Specify true to keep the canvas loaded on level unload; false otherwise.

Syntax

Copy
void SetKeepLoadedOnLevelUnload(bool keepLoaded)

SetRenderTargetName

Sets the name of the texture that is created when this canvas is rendered to a texture.

Syntax

Copy
void SetRenderTargetName(const AZStd::string& name)

SetTooltipDisplayElement

Sets the element that is to be displayed when the pointer pauses over an interactable element.

Syntax

Copy
void SetTooltipDisplayElement(AZ::EntityId entityId)

UiCanvasInputNotifications

Services notifications for the UiCanvasComponent.

OnCanvasEnterPressed

Called when the “enter” key is pressed. Sends the entity that was pressed or an invalid entity id if no element was pressed.

Syntax

Copy
OnCanvasEnterPressed(AZ::EntityId entityId)

OnCanvasEnterReleased

Called when the enter key is released. Sends the entity that was pressed or an invalid entity id if no element was pressed.

Syntax

Copy
OnCanvasEnterReleased(AZ::EntityId entityId)

OnCanvasHoverEnd

Called when an element ends being hovered.

Syntax

Copy
OnCanvasHoverEnd(AZ::EntityId entityId)

OnCanvasHoverStart

Called when an element starts being hovered.

Syntax

Copy
OnCanvasHoverStart(AZ::EntityId entityId)

OnCanvasPrimaryPressed

Called on a positional input press. Sends the entity that was pressed or an invalid entity id if no element was pressed.

Syntax

Copy
void OnCanvasPrimaryPressed(AZ::EntityId entityId)

OnCanvasPrimaryReleased

Called on a positional input release. Sends the entity that was pressed or an invalid entity id if no element was pressed.

Syntax

Copy
OnCanvasPrimaryReleased(AZ::EntityId entityId)

UiCanvasNotificationBus

Services notifications for the UiCanvasComponent.

OnAction

Maps the name of an action to the entity ID of a canvas component that triggers the action.

Syntax

Copy
void OnAction(AZ::EntityId entityId, const AZStd::string& actionName)

UiAnimationBus

Animation messages serviced by the UiCanvasComponent.

AbortSequence

Aborts the specified sequence.

Syntax

Copy
void AbortSequence (const AZStd::string& sequenceName)

GetSequencePlayingSpeed

Returns the current playing speed of the specified sequence.

Syntax

Copy
float GetSequencePlayingSpeed(const AZStd::string& sequenceName)

GetSequencePlayingTime

Returns the current playing time of the specified sequence.

Syntax

Copy
float GetSequencePlayingTime(const AZStd::string& sequenceName)

IsSequencePlaying

Returns true if the specified sequence is playing; false otherwise.

Syntax

Copy
bool IsSequencePlaying(const AZStd::string& sequenceName)

PauseSequence

Pauses the specified sequence.

Syntax

Copy
void PauseSequence (const AZStd::string& sequenceName)

ResetSequence

Resets the specified sequence to the start.

Syntax

Copy
void ResetSequence (const AZStd::string& sequenceName)

ResumeSequence

Causes the specified sequence to resume.

Syntax

Copy
void ResumeSequence (const AZStd::string& sequenceName)

SetSequencePlayingSpeed

Sets the current playing speed of the specified sequence.

Syntax

Copy
void SetSequencePlayingSpeed(const AZStd::string& sequenceName, float speed)

StartSequence

Starts playing the specified sequence.

Syntax

Copy
void StartSequence(const AZStd::string& sequenceName)

StopSequence

Stops playing the specified sequence.

Syntax

Copy
void StopSequence (const AZStd::string& sequenceName)

UiAnimationNotificationBus

Services animation notifications for the UiCanvasComponent.

OnUiAnimationEvent

Specifies the animation event for the specified sequence.

Syntax

Copy
void OnUiAnimationEvent(eUiAnimationEvent uiAnimationEvent, AZStd::string animSequenceName)

Following are possible values for the eUiAnimationEvent flag.

Copy
enum eUiAnimationEvent { eUiAnimationEvent_Started, eUiAnimationEvent_Stopped, eUiAnimationEvent_Aborted, eUiAnimationEvent_Updated };