Navigation
API > API/Runtime > API/Runtime/UMG > API/Runtime/UMG/Components
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UActorComponent
- USceneComponent
- UPrimitiveComponent
- UMeshComponent
- UWidgetComponent
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
| Type | Name | Description | |
|---|---|---|---|
| FLinearColor | BackgroundColor | The background color of the component | |
| bool | bAddedToScreen | ||
| bool | bApplyGammaCorrection | Widget components that appear in the world will be gamma corrected by the 3D renderer. | |
| bool | bDrawAtDesiredSize | Causes the render target to automatically match the desired size. | |
| bool | bEditTimeUsable | Allows the widget component to be used at editor time. For use in the VR-Editor. | |
| bool | bIsTwoSided | Is the component visible from behind? | |
| EWidgetBlendMode | BlendMode | The blend mode for the widget. | |
| bool | bManuallyRedraw | Should we wait to be told to redraw to actually draw? | |
| TObjectPtr< class UBodySetup > | BodySetup | The body setup of the displayed quad | |
| bool | bReceiveHardwareInput | Register with the viewport for hardware input from the true mouse and keyboard. | |
| bool | bRedrawRequested | Has anyone requested we redraw? | |
| bool | bWindowFocusable | Is the virtual window created to host the widget focusable? | |
| FIntPoint | CurrentDrawSize | The actual draw size, this changes based on DrawSize - or the desired size of the widget if bDrawAtDesiredSize is true. | |
| float | CylinderArcAngle | Curvature of a cylindrical widget in degrees. | |
| FIntPoint | DrawSize | The size of the displayed quad. | |
| EWidgetGeometryMode | GeometryMode | Controls the geometry of the widget component. See EWidgetGeometryMode. | |
| FVector2D | LastLocalHitLocation | The relative location of the last hit on this component | |
| double | LastWidgetRenderTime | What was the last time we rendered the widget? | |
| 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 | |
| TObjectPtr< UMaterialInterface > | MaskedMaterial | The material instance for masked widget components. | |
| TObjectPtr< UMaterialInterface > | MaskedMaterial_OneSided | The material instance for masked, one-sided widget components. | |
| TObjectPtr< UMaterialInstanceDynamic > | MaterialInstance | The dynamic instance of the material that the render target is attached to | |
| 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) | |
| TObjectPtr< UMaterialInterface > | OpaqueMaterial | The material instance for opaque widget components | |
| TObjectPtr< UMaterialInterface > | OpaqueMaterial_OneSided | The material instance for opaque, one-sided widget components | |
| TObjectPtr< 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. | |
| FVector2D | Pivot | The Alignment/Pivot point that the widget is placed at relative to the position. | |
| float | RedrawTime | The time in between draws, if 0 - we would redraw every frame. | |
| TObjectPtr< UTextureRenderTarget2D > | RenderTarget | The target to which the user widget is rendered | |
| FName | SharedLayerName | Layer Name the widget will live on | |
| TSharedPtr< class SVirtualWindow > | SlateWindow | The slate window that contains the user widget content | |
| EWidgetSpace | Space | The coordinate space in which to render the widget | |
| ETickMode | TickMode | ||
| bool | TickWhenOffscreen | Should the component tick the widget when it's off screen? | |
| EWidgetTimingPolicy | TimingPolicy | How this widget should deal with timing, pausing, etc. | |
| FLinearColor | TintColorAndOpacity | Tint color and opacity for this component | |
| TObjectPtr< UMaterialInterface > | TranslucentMaterial | The material instance for translucent widget components | |
| TObjectPtr< UMaterialInterface > | TranslucentMaterial_OneSided | The material instance for translucent, one-sided widget components | |
| TSubclassOf< UUserWidget > | WidgetClass | The class of User Widget to create and display an instance of | |
| FWidgetRenderer * | WidgetRenderer | Helper class for drawing widgets to a render target. | |
| EWindowVisibility | WindowVisibility | The visibility of the virtual window created to host the widget |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UWidgetComponent
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | ApplyComponentInstanceData
(
FWidgetComponentInstanceData* ComponentInstanceData |
||
| bool | Just because the user attempts to receive hardware input does not mean it's possible. | ||
| float | Returns the width of the widget component taking GeometryMode into account. | ||
| void | DrawWidgetToRenderTarget
(
float DeltaTime |
Draws the current widget to the render target if possible. | |
| EWidgetBlendMode | GetBlendMode () |
Gets the blend mode for the widget. | |
| FVector2D | Returns the "actual" draw size of the quad in the world | ||
| double | Returns current absolute time, respecting TimingPolicy. | ||
| float | Defines the curvature of the widget component when using EWidgetGeometryMode::Cylinder; ignored otherwise. | ||
| TTuple< FVector, FVector2D > | GetCylinderHitLocation
(
FVector WorldHitLocation, |
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. | |
| bool | |||
| FVector2D | GetDrawSize () |
Returns the "specified" draw size of the quad in the world | |
| bool | |||
| EWidgetGeometryMode | |||
| TArray< FWidgetAndPointer > | GetHitWidgetPath
(
FVector WorldHitLocation, |
Returns the list of widgets with their geometry and the cursor position transformed into this Widget component's space. | |
| TArray< FWidgetAndPointer > | GetHitWidgetPath
(
FVector2D WidgetSpaceHitCoordinate, |
Returns the list of widgets with their geometry and the cursor position transformed into this Widget space. | |
| FVector2D | Gets the last local location that was hit | ||
| void | GetLocalHitLocation
(
FVector WorldHitLocation, |
Converts a world-space hit result to a hit location on the widget | |
| bool | |||
| UMaterialInstanceDynamic * | Returns the dynamic material instance used to render the user widget | ||
| ULocalPlayer * | Gets the local player that owns this widget component. | ||
| FVector2D | GetPivot () |
Returns the pivot point where the UI is rendered about the origin. | |
| bool | |||
| float | |||
| UTextureRenderTarget2D * | Returns the render target to which the user widget is rendered | ||
| const TSharedPtr< SWidget > & | Returns the Slate widget that was assigned to this component, if any | ||
| TSharedPtr< SWindow > | Returns the window containing the user widget content | ||
| bool | Gets whether the widget ticks when offscreen or not | ||
| bool | GetTwoSided () |
Gets whether the widget is two-sided or not | |
| UUserWidget * | Returns the user widget object displayed by this component | ||
| TSharedPtr< SWindow > | Get the fake window we create for widgets displayed in the world. | ||
| UUserWidget * | GetWidget () |
Gets the widget that is used by this Widget Component. | |
| TSubclassOf< UUserWidget > | Returns the class of the user widget displayed by this component | ||
| EWidgetSpace | |||
| bool | |||
| EWindowVisibility | Gets the visibility of the virtual window created to host the widget focusable. | ||
| void | InitWidget () |
Ensures the user widget is initialized | |
| bool | Returns true if the the Slate window is visible and that the widget is also visible, false otherwise. | ||
| FVector2D | ModifyProjectedLocalPosition
(
const FGeometry& ViewportGeometry, |
Hook to allow this component modify the local position of the widget after it has been projected from world space to screen space. | |
| void | OnLevelRemovedFromWorld
(
ULevel* InLevel, |
||
| void | RegisterHitTesterWithViewport
(
TSharedPtr< SViewport > ViewportWidget |
||
| void | |||
| void | Release resources associated with the widget. | ||
| void | |||
| void | Requests that the widget be redrawn. | ||
| void | Requests that the widget have it's render target updated, if TickMode is disabled, this will force a tick to happen to update the render target. | ||
| void | SetBackgroundColor
(
const FLinearColor NewBackgroundColor |
Sets the background color and opacityscale for this widget | |
| void | SetBlendMode
(
const EWidgetBlendMode NewBlendMode |
Sets the blend mode to use for this widget | |
| void | SetCylinderArcAngle
(
const float InCylinderArcAngle |
Defines the curvature of the widget component when using EWidgetGeometryMode::Cylinder; ignored otherwise. | |
| void | SetDrawAtDesiredSize
(
bool bInDrawAtDesiredSize |
||
| void | SetDrawSize
(
FVector2D Size |
Sets the draw size of the quad in the world | |
| void | SetEditTimeUsable
(
bool Value |
||
| void | SetGeometryMode
(
EWidgetGeometryMode InGeometryMode |
||
| void | SetInitialLayerZOrder
(
int32 NewLayerZOrder |
Sets layer z order used when this widget is initialized | |
| void | SetInitialSharedLayerName
(
FName NewSharedLayerName |
Sets shared layer name used when this widget is initialized | |
| void | SetManuallyRedraw
(
bool bUseManualRedraw |
||
| 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) | |
| void | SetOwnerPlayer
(
ULocalPlayer* LocalPlayer |
Sets the local player that owns this widget component. | |
| void | SetPivot
(
const FVector2D& InPivot |
||
| void | SetRedrawTime
(
float InRedrawTime |
||
| void | SetSlateWidget
(
const TSharedPtr< SWidget >& InSlateWidget |
Sets a Slate widget to be rendered. | |
| void | SetTickMode
(
ETickMode InTickMode |
Sets the Tick mode of the Widget Component. | |
| void | SetTickWhenOffscreen
(
const bool bWantTickWhenOffscreen |
Sets whether the widget ticks when offscreen or not | |
| void | SetTintColorAndOpacity
(
const FLinearColor NewTintColorAndOpacity |
Sets the tint color and opacity scale for this widget | |
| void | SetTwoSided
(
const bool bWantTwoSided |
Sets whether the widget is two-sided or not | |
| void | SetWidget
(
UUserWidget* Widget |
Sets the widget to use directly. | |
| void | SetWidgetClass
(
TSubclassOf< UUserWidget > InWidgetClass |
Sets the widget class used to generate the widget for this component | |
| void | SetWidgetSpace
(
EWidgetSpace NewSpace |
||
| void | SetWindowFocusable
(
bool bInWindowFocusable |
||
| void | SetWindowVisibility
(
EWindowVisibility InVisibility |
Sets the visibility of the virtual window created to host the widget focusable. | |
| bool | Allows subclasses to control if the widget should be drawn. Called right before we draw the widget. | ||
| void | UnregisterHitTesterWithViewport
(
TSharedPtr< SViewport > ViewportWidget |
||
| void | |||
| void | UpdateBodySetup
(
bool bDrawSizeChanged |
Ensures the body setup is initialized and updates it if needed. | |
| void | |||
| void | Updates the dynamic parameters on the material instance, without re-creating it | ||
| void | UpdateRenderTarget
(
FIntPoint DesiredRenderTargetSize |
Ensure the render target is initialized and updates it if needed. | |
| void | UpdateWidget () |
Ensures the 3d window is created its size and content. |
Overridden from UPrimitiveComponent
| Type | Name | Description | |
|---|---|---|---|
| FPrimitiveSceneProxy * | UPrimitiveComponent Interface | ||
| UBodySetup * | GetBodySetup () |
Return the BodySetup to use for this PrimitiveComponent (single body case) | |
| FCollisionShape | GetCollisionShape
(
float Inflation |
Return a CollisionShape that most closely matches this primitive. | |
| UMaterialInterface * | GetMaterial
(
int32 ElementIndex |
Returns the material used by the element at the specified index | |
| int32 | Return number of material elements in this primitive | ||
| void | GetUsedMaterials
(
TArray< UMaterialInterface* >& OutMaterials, |
Retrieves the materials used in this component | |
| void | SetMaterial
(
int32 ElementIndex, |
Changes the material applied to an element of the mesh. |
Overridden from USceneComponent
| Type | Name | Description | |
|---|---|---|---|
| FBoxSphereBounds | CalcBounds
(
const FTransform& LocalToWorld |
Calculate the bounds of the component. Default behavior is a bounding box/sphere of zero size. | |
| void | Overridable internal function to respond to changes in the hidden in game value of the component. |
Overridden from UActorComponent
| Type | Name | Description | |
|---|---|---|---|
| void | BeginPlay () |
UActorComponent Interface | |
| void | DestroyComponent
(
bool bPromoteChildren |
Unregister the component, remove it from its outer Actor's Components array and mark for pending kill. | |
| void | EndPlay
(
const EEndPlayReason::Type EndPlayReason |
Ends gameplay for this component. | |
| TStructOnScope< FActorComponentInstanceData > | Called before we throw away components during RerunConstructionScripts, to cache any data we wish to persist across that operation | ||
| void | OnRegister () |
Called when a component is registered, after Scene is set, but before CreateRenderState_Concurrent or OnCreatePhysicsState are called. | |
| void | OnUnregister () |
Called when a component is unregistered. | |
| void | TickComponent
(
float DeltaTime, |
Function called every frame on this ActorComponent. |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| bool | CanEditChange
(
const FProperty* InProperty |
Called by the editor to query whether a property of this object is allowed to be modified. | |
| void | PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
Called when a property on this object has been modified externally | |
| void | Handles reading, writing, and reference collecting using FArchive. |
Overridden from UObjectBaseUtility
| Type | Name | Description | |
|---|---|---|---|
| bool | Called during cluster construction if the object can be added to a cluster |
Constants
| Name | Description |
|---|---|
| WidgetHitTester | The hit tester to use for this component |