I am trying to use the following code as a callback lambda:
auto notificationClicked = [](const FGeometry&, const FPointerEvent&) -> FReply
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Notification was clicked"));
// we restore the game window no matter where it is
UGameEngine* engine = Cast<UGameEngine>(GEngine);
if (engine != nullptr)
{
TSharedPtr<SWindow> windowRef = engine->GameViewportWindow.Pin();
if (windowRef.IsValid())
{
SWindow* window = windowRef.Get();
if (window != nullptr)
{
if (window->IsWindowMinimized())
{
window->Restore();
window->ShowWindow();
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Game was minimised"));
}
window->BringToFront(true);
window->HACK_ForceToFront();
} else {
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Window was nullptr"));
}
} else {
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Window Ref was not valid"));
}
} else {
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Engine was nullptr"));
}
return FReply::Handled();
};
However I am getting the message “Engine was nullptr”. Is there any reason why the engine cast would return nullptr?
I am including “Runtime/Engine/Classes/Engine/GameEngine.h”