I’m making a C++ project with Unreal Engine 4 and I cannot get FMessageEndPoint objects to work when making a shipping build. They work in Development build and in the editor.
Here is my code for declaring the endpoint:
TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe> MessagEndPointPauseGame;
Here is my code for declaring the message system callback:
void HandlePauseGame(const FEventPauseGame& Message,
const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context);
And lastly, here is the code for building the endpoints and subscribing to the message callback:
// Set up the Message End Points.
MessagEndPointPauseGame = FMessageEndpoint::Builder("AMia").
Handling<FEventPauseGame>(this, &AMia::HandlePauseGame).
ReceivingOnThread(ENamedThreads::GameThread);
// Subscribe to the message types.
if (MessagEndPointPauseGame.IsValid())
{
MessagEndPointPauseGame->Subscribe<FEventPauseGame>();
}
else
{
// The message title.
FText Title = FText::FromString("Error");
FMessageDialog::Debugf(
FText::FromString("Pause Event could not be subscribed to by class AMia."),
&Title);
FGenericPlatformMisc::RequestExit(true);
}
For some reason the shared pointer isn’t valid, which tells me that the builder failed to create an end point. I checked this in the Builder code using breakpoints and it seems to not work and I don’t know why. Is this a bug, or am I doing something wrong? Is there some setting I have to enable for the shipping build to make it work? I am following the code from EngineService.cpp so I am certain that I am coding things correctly.
Please let me know if there is a fix. Thanks!