UWidgetComponent

The widget component provides a surface in the 3D environment on which to render widgets normally rendered to the screen.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

UMG

Header

/Engine/Source/Runtime/UMG/Public/Components/WidgetComponent.h

Include

#include "Components/WidgetComponent.h"

Syntax

class UWidgetComponent : public UMeshComponent

Remarks

The widget component provides a surface in the 3D environment on which to render widgets normally rendered to the screen. Widgets are first rendered to a render target, then that render target is displayed in the world.

Material Properties set by this component on whatever material overrides the default. SlateUI [Texture] BackColor [Vector] TintColorAndOpacity [Vector] OpacityFromTexture [Scalar]

Variables

Name Description

Protected variable

FLinearColor

 

BackgroundColor

The background color of the component

Protected variable

bool

 

bAddedToScreen

Protected variable

bool

 

bApplyGammaCorrection

Widget components that appear in the world will be gamma corrected by the 3D renderer.

Protected variable

bool

 

bDrawAtDesiredSize

Causes the render target to automatically match the desired size.

Protected variable

bool

 

bEditTimeUsable

Allows the widget component to be used at editor time. For use in the VR-Editor.

Protected variable

bool

 

bIsTwoSided

Is the component visible from behind?

Protected variable

EWidgetBlendMod...

 

BlendMode

The blend mode for the widget.

Protected variable

bool

 

bManuallyRedraw

Should we wait to be told to redraw to actually draw?

Protected variable

UBodySetup *...

 

BodySetup

The body setup of the displayed quad

Protected variable

bool

 

bReceiveHardwareInput

Register with the viewport for hardware input from the true mouse and keyboard.

Protected variable

bool

 

bRedrawRequested

Has anyone requested we redraw?

Protected variable

bool

 

bWindowFocusable

Is the virtual window created to host the widget focusable?

Protected variable

FIntPoint

 

CurrentDrawSize

The actual draw size, this changes based on DrawSize - or the desired size of the widget if bDrawAtDesiredSize is true.

Protected variable

TWeakPtr< SWidg...

 

CurrentSlateWidget

The slate widget currently being drawn.

Protected variable

float

 

CylinderArcAngle

Curvature of a cylindrical widget in degrees.

Protected variable

FIntPoint

 

DrawSize

The size of the displayed quad.

Protected variable

EWidgetGeometry...

 

GeometryMode

Controls the geometry of the widget component. See EWidgetGeometryMode.

Protected variable

FVector2D

 

LastLocalHitLocation

The relative location of the last hit on this component

Protected variable

double

 

LastWidgetRenderTime

What was the last time we rendered the widget?

Protected variable

int32

 

LayerZOrder

ZOrder the layer will be created on, note this only matters on the first time a new layer is created, subsequent additions to the same layer will use the initially defined ZOrder

Protected variable

UMaterialInterf...

 

MaskedMaterial

The material instance for masked widget components.

Protected variable

UMaterialInterf...

 

MaskedMaterial_OneSided

The material instance for masked, one-sided widget components.

Protected variable

UMaterialInstan...

 

MaterialInstance

The dynamic instance of the material that the render target is attached to

Protected variable

float

 

OpacityFromTexture

Sets the amount of opacity from the widget's UI texture to use when rendering the translucent or masked UI to the viewport (0.0-1.0)

Protected variable

UMaterialInterf...

 

OpaqueMaterial

The material instance for opaque widget components

Protected variable

UMaterialInterf...

 

OpaqueMaterial_OneSided

The material instance for opaque, one-sided widget components

Protected variable

ULocalPlayer &#...

 

OwnerPlayer

The owner player for a widget component, if this widget is drawn on the screen, this controls what player's screen it appears on for split screen, if not set, users player 0.

Protected variable

FVector2D

 

Pivot

The Alignment/Pivot point that the widget is placed at relative to the position.

Protected variable

float

 

RedrawTime

The time in between draws, if 0 - we would redraw every frame.

Protected variable

UTextureRenderT...

 

RenderTarget

The target to which the user widget is rendered

Protected variable

FName

 

SharedLayerName

Layer Name the widget will live on

Protected variable

TSharedPtr< SWi...

 

SlateWidget

The Slate widget to be displayed by this component.

Protected variable

TSharedPtr< cla...

 

SlateWindow

The slate window that contains the user widget content

Protected variable

EWidgetSpace

 

Space

The coordinate space in which to render the widget

Protected variable

bool

 

TickWhenOffscreen

Should the component tick the widget when it's off screen?

Protected variable

EWidgetTimingPo...

 

TimingPolicy

How this widget should deal with timing, pausing, etc.

Protected variable

FLinearColor

 

TintColorAndOpacity

Tint color and opacity for this component

Protected variable

UMaterialInterf...

 

TranslucentMaterial

The material instance for translucent widget components

Protected variable

UMaterialInterf...

 

TranslucentMaterial_OneSided

The material instance for translucent, one-sided widget components

Protected variable

UUserWidget ...

 

Widget

The User Widget object displayed and managed by this component

Protected variable

TSubclassOf< UU...

 

WidgetClass

The class of User Widget to create and display an instance of

Protected variable

FWidgetRenderer...

 

WidgetRenderer

Helper class for drawing widgets to a render target.

Protected variable

EWindowVisibili...

 

WindowVisibility

The visibility of the virtual window created to host the widget

Constructors

Name Description

Public function

UWidgetComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function

void

 

ApplyComponentInstanceData

Protected function Const

bool

 

CanReceiveHardwareInput()

Just because the user attempts to receive hardware input does not mean it's possible.

Protected function Const

float

 

ComputeComponentWidth()

Returns the width of the widget component taking GeometryMode into account.

Protected function Virtual

void

 

DrawWidgetToRenderTarget

(
    float DeltaTime
)

Draws the current widget to the render target if possible.

Public function Const

EWidgetBlend...

 

GetBlendMode()

Gets the blend mode for the widget.

Public function Const

FVector2D

 

GetCurrentDrawSize()

Returns the "actual" draw size of the quad in the world

Protected function Const

double

 

GetCurrentTime()

Returns current absolute time, respecting TimingPolicy.

Public function Const

float

 

GetCylinderArcAngle()

Defines the curvature of the widget component when using EWidgetGeometryMode::Cylinder; ignored otherwise.

Public function Const

TTuple< FVec...

 

GetCylinderHitLocation

(
    FVector WorldHitLocation,
    FVector WorldHitDirection
)

When using EWidgetGeometryMode::Cylinder, continues the trace from the front face of the widget component into the cylindrical geometry and returns adjusted hit results information.

Public function Const

bool

 

GetDrawAtDesiredSize()

Public function Const

FVector2D

 

GetDrawSize()

Returns the "specified" draw size of the quad in the world

Public function Const

bool

 

GetEditTimeUsable()

Public function Const

EWidgetGeome...

 

GetGeometryMode()

Public function

TArray< FWid...

 

GetHitWidgetPath

(
    FVector WorldHitLocation,
    bool bIgnoreEnabledStatus,
    float CursorRadius
)

Returns the list of widgets with their geometry and the cursor position transformed into this Widget component's space.

Public function

TArray< FWid...

 

GetHitWidgetPath

(
    FVector2D WidgetSpaceHitCoordinate,
    bool bIgnoreEnabledStatus,
    float CursorRadius
)

Returns the list of widgets with their geometry and the cursor position transformed into this Widget space.

Public function Const

FVector2D

 

GetLastLocalHitLocation()

Gets the last local location that was hit

Public function Virtual Const

void

 

GetLocalHitLocation

(
    FVector WorldHitLocation,
    FVector2D& OutLocalHitLocation
)

Converts a world-space hit result to a hit location on the widget

Public function Const

bool

 

GetManuallyRedraw()

Public function Const

UMaterialIns...

 

GetMaterialInstance()

Returns the dynamic material instance used to render the user widget

Public function Const

ULocalPlayer...

 

GetOwnerPlayer()

Gets the local player that owns this widget component.

Public function Const

FVector2D

 

GetPivot()

Returns the pivot point where the UI is rendered about the origin.

Public function Const

bool

 

GetReceiveHardwareInput()

Public function Const

float

 

GetRedrawTime()

Public function Const

UTextureRend...

 

GetRenderTarget()

Returns the render target to which the user widget is rendered

Public function Const

const TShare...

 

GetSlateWidget()

Returns the Slate widget that was assigned to this component, if any

Public function Const

TSharedPtr< ...

 

GetSlateWindow()

Returns the window containing the user widget content

Public function Const

bool

 

GetTickWhenOffscreen()

Gets whether the widget ticks when offscreen or not

Public function Const

bool

 

GetTwoSided()

Gets whether the widget is two-sided or not

Public function Const

UUserWidget ...

 

GetUserWidgetObject()

Returns the user widget object displayed by this component

Public function Const

TSharedPtr< ...

 

GetVirtualWindow()

Get the fake window we create for widgets displayed in the world.

Public function Const

TSubclassOf<...

 

GetWidgetClass()

Returns the class of the user widget displayed by this component

Public function Const

EWidgetSpace

 

GetWidgetSpace()

Public function Const

bool

 

GetWindowFocusable()

Public function Const

EWindowVisib...

 

GetWindowVisiblility()

Gets the visibility of the virtual window created to host the widget focusable.

Public function Virtual

void

 

InitWidget()

Ensures the user widget is initialized

Public function Virtual

FVector2D

 

ModifyProjectedLocalPosition

(
    const FGeometry& ViewportGeometry,
    const FVector2D& LocalPosition
)

Hook to allow this component modify the local position of the widget after it has been projected from world space to screen space.

Protected function

void

 

OnLevelRemovedFromWorld

(
    ULevel* InLevel,
    UWorld* InWorld
)

Protected function

void

 

RegisterHitTesterWithViewport

(
    TSharedPtr< SViewport > ViewportWid...
)

Protected function

void

 

RegisterWindow()

Public function Virtual

void

 

ReleaseResources()

Release resources associated with the widget.

Protected function

void

 

RemoveWidgetFromScreen()

Public function Virtual

void

 

RequestRedraw()

Requests that the widget be redrawn.

Public function

void

 

SetBackgroundColor

(
    const FLinearColor NewBackgroundCol...
)

Sets the background color and opacityscale for this widget

Public function

void

 

SetBlendMode

(
    const EWidgetBlendMode NewBlendMode
)

Sets the blend mode to use for this widget

Public function

void

 

SetCylinderArcAngle

(
    const float InCylinderArcAngle
)

Defines the curvature of the widget component when using EWidgetGeometryMode::Cylinder; ignored otherwise.

Public function

void

 

SetDrawAtDesiredSize

(
    bool bInDrawAtDesiredSize
)

Public function

void

 

SetDrawSize

(
    FVector2D Size
)

Sets the draw size of the quad in the world

Public function

void

 

SetEditTimeUsable

(
    bool Value
)

Public function

void

 

SetGeometryMode

(
    EWidgetGeometryMode InGeometryMode
)

Public function

void

 

SetInitialLayerZOrder

(
    int32 NewLayerZOrder
)

Sets layer z order used when this widget is initialized

Public function

void

 

SetInitialSharedLayerName

(
    FName NewSharedLayerName
)

Sets shared layer name used when this widget is initialized

Public function

void

 

SetManuallyRedraw

(
    bool bUseManualRedraw
)

Public function

void

 

SetOpacityFromTexture

(
    const float NewOpacityFromTexture
)

Sets how much opacity from the UI widget's texture alpha is used when rendering to the viewport (0.0-1.0)

Public function

void

 

SetOwnerPlayer

(
    ULocalPlayer* LocalPlayer
)

Sets the local player that owns this widget component.

Public function

void

 

SetPivot

(
    const FVector2D& InPivot
)

Public function

void

 

SetRedrawTime

(
    float InRedrawTime
)

Public function Virtual

void

 

SetSlateWidget

(
    const TSharedPtr< SWidget >& InSla...
)

Sets a Slate widget to be rendered.

Public function

void

 

SetTickWhenOffscreen

(
    const bool bWantTickWhenOffscreen
)

Sets whether the widget ticks when offscreen or not

Public function

void

 

SetTintColorAndOpacity

(
    const FLinearColor NewTintColorAndO...
)

Sets the tint color and opacity scale for this widget

Public function

void

 

SetTwoSided

(
    const bool bWantTwoSided
)

Sets whether the widget is two-sided or not

Public function Virtual

void

 

SetWidget

(
    UUserWidget* Widget
)

Sets the widget to use directly.

Public function

void

 

SetWidgetClass

(
    TSubclassOf< UUserWidget > InWidget...
)

Sets the widget class used to generate the widget for this component

Public function

void

 

SetWidgetSpace

(
    EWidgetSpace NewSpace
)

Public function

void

 

SetWindowFocusable

(
    bool bInWindowFocusable
)

Public function

void

 

SetWindowVisibility

(
    EWindowVisibility InVisibility
)

Sets the visibility of the virtual window created to host the widget focusable.

Protected function Virtual Const

bool

 

ShouldDrawWidget()

Allows subclasses to control if the widget should be drawn. Called right before we draw the widget.

Protected function

void

 

UnregisterHitTesterWithViewport

(
    TSharedPtr< SViewport > ViewportWid...
)

Protected function

void

 

UnregisterWindow()

Public function

void

 

UpdateBodySetup

(
    bool bDrawSizeChanged
)

Ensures the body setup is initialized and updates it if needed.

Protected function

void

 

UpdateMaterialInstance()

Public function

void

 

UpdateMaterialInstanceParameters()

Updates the dynamic parameters on the material instance, without re-creating it

Public function Virtual

void

 

UpdateRenderTarget

(
    FIntPoint DesiredRenderTargetSize
)

Ensure the render target is initialized and updates it if needed.

Public function Virtual

void

 

UpdateWidget()

Ensures the 3d window is created its size and content.

Overridden from UPrimitiveComponent

Name Description

Public function Virtual

FPrimitiveSc...

 

CreateSceneProxy()

UPrimitiveComponent Interface

Public function Virtual

UBodySetup &...

 

GetBodySetup()

Return the BodySetup to use for this PrimitiveComponent (single body case)

Public function Virtual Const

FCollisionSh...

 

GetCollisionShape

(
    float Inflation
)

Return a CollisionShape that most closely matches this primitive.

Public function Virtual Const

UMaterialInt...

 

GetMaterial

(
    int32 ElementIndex
)

Returns the material used by the element at the specified index

Public function Virtual Const

int32

 

GetNumMaterials()

Return number of material elements in this primitive

Public function Virtual Const

void

 

GetUsedMaterials

(
    TArray< UMaterialInterface* > ...,
    bool bGetDebugMaterials
)

Retrieves the materials used in this component

Public function Virtual

void

 

SetMaterial

(
    int32 ElementIndex,
    UMaterialInterface* Material
)

Changes the material applied to an element of the mesh.

Overridden from USceneComponent

Name Description

Public function Virtual Const

FBoxSphereBo...

 

CalcBounds

(
    const FTransform& LocalToWorld
)

Calculate the bounds of the component. Default behavior is a bounding box/sphere of zero size.

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

BeginPlay()

UActorComponent Interface

Public function Virtual

void

 

DestroyComponent

(
    bool bPromoteChildren
)

Unregister the component, remove it from its outer Actor's Components array and mark for pending kill.

Public function Virtual

void

 

EndPlay

(
    const EEndPlayReason::Type EndPlayR...
)

Ends gameplay for this component.

Public function Virtual Const

TStructOnSco...

 

GetComponentInstanceData()

Called before we throw away components during RerunConstructionScripts, to cache any data we wish to persist across that operation

Public function Virtual

void

 

OnRegister()

Called when a component is registered, after Scene is set, but before CreateRenderState_Concurrent or OnCreatePhysicsState are called.

Public function Virtual

void

 

OnUnregister()

Called when a component is unregistered.

Public function Virtual

void

 

TickComponent

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorComponentTickFunction* T...
)

Function called every frame on this ActorComponent.

Overridden from UObject

Name Description

Public function Virtual Const

bool

 

CanEditChange

(
    const FProperty* InProperty
)

Called by the editor to query whether a property of this object is allowed to be modified.

Public function Virtual Const

bool

 

IsDestructionThreadSafe()

Called during garbage collection to determine if an object can have its destructor called on a worker thread.

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Constants

Name

Description

WidgetHitTester

The hit tester to use for this component

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss