I’m building a plugin that during the runtime of a game, the plugin will create a socket to a service running on localhost.
Essentially, I’m trying to build a check into the plugin so that if the when the plugin is being executed in the editor, it will not attempt to create this socket.
I’m trying to do this by checking WorldType in my CreateInputDevice implementation.
This is the relevant block of code:
TSharedPtr< class IInputDevice > MyPluginImpl::CreateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler)
{
if (FModuleManager::Get().IsModuleLoaded("MyPlugin"))
{
UE_LOG(LogPureWeb, Warning, TEXT("Plugin Started"));
}
m_input = new CreateInputDevice(InMessageHandler);
auto input = MakeShareable(m_input);
if ((GEngine) && (GEngine->GetWorld()->WorldType == EWorldType::Game)){
//Create socket
}
}
The problem is that when it hits the GEngine check, it fails on GEngine->GetWorld(), because it says GEngine is undefined.
I have included Engine.h, and I use GEngine elsewhere in the plugin, but it appears to not be available in this method.
I am clearly not going about this correctly, so any advice would be appreciated.
Thanks