Hi,
My goal is to show a popup on top of everything when a disconnection occurs.
I was able to successfully do it with Unreal 4.27. Now, I need to make it happen on the version 4.12.
I changed FSoftClassPath to FStringClassReference basically and tried to call the TryLoadClass method of it.
In version 4.12, it returns a null.
I tried to step in the engine code and it seems it is unable to create a linker.
Here is the code to show the popup. This exact code works (runs and show the popup) with 4.27 and compiles on both 4.12 and 4.27.
void FClassNamePluginModule::TryShowConnectionLostPopup()
{
if (!m_showConnectionLostPopup)
return;
UGameInstance* gameInstance = nullptr;
TArray<APlayerController*> playerList;
GEngine->GetAllLocalPlayerControllers(playerList);
if (playerList.Num() > 0)
{
gameInstance = playerList[0]->GetGameInstance();
}
else if(GEngine->GetWorld() != nullptr)
{
gameInstance = GEngine->GetWorld()->GetGameInstance();
}
if (gameInstance == nullptr)
return;
FString path(L"WidgetBlueprint'/PluginName/Blueprints/UBP_WidgetNotification.UBP_WidgetNotification_C'");
#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION < 15
FStringClassReference notificationClasstRef(path);
#else
FSoftClassPath notificationClasstRef(path);
#endif
UClass* notificationClass = notificationClasstRef.TryLoadClass<UUserWidget>();
if (notificationClass)
{
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("ThirdPartyLibraryError3", "DC 3"));
UUserWidget* notificationWidget = CreateWidget<UUserWidget>(gameInstance, notificationClass);
if (notificationWidget)
{
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("ThirdPartyLibraryError4", "DC 4"));
notificationWidget->AddToViewport();
m_showConnectionLostPopup = false;
}
}
}
Would you have any idea what I am doing wrong? Also, I checked the the notificationClasstRef variable is NOT null and Valid (called the method IsValid())
Thank you