RealDocs

UUserWidget

class UMG Blueprint Since 4.5
#include "Blueprint/UserWidget.h"

Description

The base class for all Blueprint UI widgets. Subclass it in Blueprint or C++ to create HUDs, menus, and any in-game UI. Create instances with CreateWidget<T>() and add to the viewport with AddToViewport().

Signature

class UUserWidget : public UWidget, public INamedSlotInterface

Caveats & Gotchas

  • Native tick is disabled by default (DisableNativeTick metadata). If you override Tick in C++, you must call SetCanEverTick(true) in the constructor or it will not fire.
  • Do not add a widget to the viewport in its own constructor — the widget is not yet fully initialized. Use NativeConstruct (analogous to BeginPlay).
  • Widgets are not actors and do not exist in world space by default. Use UWidgetComponent to attach a widget to a 3D actor.
  • CreateWidget requires a valid APlayerController or UWorld as the outer. Pass a null outer and it will assert.

Example

Create and show a HUD widget C++
// In AMyHUD or APlayerController:
if (HUDWidgetClass)
{
    UMyHUDWidget* HUD = CreateWidget<UMyHUDWidget>(GetWorld(), HUDWidgetClass);
    HUD->AddToViewport();
}

Functions (4)

Rendering
1
Access Type Name
public function UUserWidget::SetVisibility
Utility
2
Access Type Name
public function UUserWidget::GetOwningPlayer
public function UUserWidget::RemoveFromParent
Viewport
1
Access Type Name
public function UUserWidget::AddToViewport

Tags

Version History

Introduced in: 4.5

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.