Hi all,
i’m actually using this code to create a Widget and add it to viewport, but fails on createwidget function.
UHUDController::UHUDController() {
ConstructorHelpers::FClassFinder<UMainMenuWidget> WidgetAsset(TEXT("WidgetBlueprint'/Game/HUD/MainMenu/MainMenu.MainMenu_C'"));
if (WidgetAsset.Succeeded())
{
WidgetClass = WidgetAsset.Class;
}
if (WidgetClass)
{
MainMenuWidget = CreateWidget<UMainMenuWidget>(GetWorld(), WidgetClass);
if (MainMenuWidget)
{
MainMenuWidget->AddToViewport();
}
else {
GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Yellow, TEXT("125125125"));
}
}
}
The engine prints the debug message, so taht means that MainMenuWidget is actually null. Any reason for that? WidgetClass isn’t null since the code inside the if works. Any idea?