Any widgets I add to the player’s viewport are invisible. Not invisible as a widget visibility state, if I try to change their visibility state to visible they still don’t appear on the player’s screen. I’m with this issue over a week now and I can’t find anywhere an answer for that.
EDIT
GameHUD.h
void AGameHUD::CreateInvWidget()
{
//This function creates invWidget and is called on AGameHUD's begin play function
if (invWidgetTemplate)
{
invWidget = CreateWidget<UMainInvWidget>(GetWorld(), invWidgetTemplate.GetDefaultObject()->StaticClass());
if (invWidget) {
invWidget->AddToViewport(0);
invWidget->SetVisibility(ESlateVisibility::Visible);
if (invWidget->GetVisibility() == ESlateVisibility::Visible)
{
//I get this message when playing the game
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "invwidget visible");
}
}
else
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "invWidget is null! @GameHUD::BeginPlay");
}
else {
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "invWidgetTemplate is null! @GameHUD::BeginPlay");
}
}
ShooterGameHUD blueprint that inherits from GameHUD.h
(added this Add To Viewport node on the Event Toggle Show Hide Inv Widget only for debugging purposes)
Construct event from the main inventory widget, which inherits from UMainInvWidget (an empty class that’s only used so I can reference this widget in c++) .
(sorry for my bad english)
Thanks in advance!