As an example, here’s the barebones of how we load our HUD asset in our game:
/** HUD UMG widget class. */
UPROPERTY( Category=Widgets, EditDefaultsOnly )
TSubclassOf<UUserWidget> HUDWidgetClass;
/** HUD UMG widget instance. */
UPROPERTY()
UMyHUDWidget* HUDWidgetInstance;
void AMyHUD::PostInitializeComponents()
{
Super::PostInitializeComponents();
HUDWidgetInstance = CreateWidget<UMyHUDWidget>( PCOwner, HUDWidgetClass );
check( HUDWidgetInstance != nullptr );
}