At 14:50 in video titled “43. Challenge: Leaving A Server”, Sam says “Remember the menu interface is set by a superclass. It’s a variable on a superclass.” However, every time I click Quit on the InGameMenu, this code below runs…
void UInGameMenu::QuitPressed()
{
UE_LOG(LogTemp, Warning, TEXT("QuitPressed() called."));
if (MenuInterface != nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("MenuInterface is not null."));
Teardown();
MenuInterface->LoadMainMenuMap();
} else
{
UE_LOG(LogTemp, Error, TEXT("MenuInterface is null."));
}
}
and this is printed to the Output Log:
Warning: QuitPressed() called.
Error: MenuInterface is null.
I’ve checked the Github repo and I see that UPuzzlePlatformsGameInstance::InGameLoadMenu() calls SetMenuInterface(this) on the in-game menu, so I don’t understand why it would be null at the time Quit is clicked.
For comparison, my version of InGameLoadMenu() is below.
void UPuzzlePlatformsGameInstance::LoadInGameMenu()
{
if (!InGameMenuClass) { return; }
// Menu name changed to avoid shadowing
UMenuWidget* InGameMenu = CreateWidget<UMenuWidget>(this, InGameMenuClass);
if (!InGameMenu) { return; }
InGameMenu->Setup();
InGameMenu->SetMenuInterface(this);
}