【发布时间】:2020-06-23 11:24:37
【问题描述】:
我正在尝试使用通过线程读取传入消息的 dll。使用 Blueprint 类导入虚幻引擎,因为我无法获取传入消息。我计划在 dll 中有一个事件,我会将事件处理程序放入虚幻引擎代码中。
你能帮帮我吗,这可能吗?如果它是如何使用它的?
我正在尝试类似enter link description here
【问题讨论】:
标签: c++ events unreal-engine4 eventhandler
我正在尝试使用通过线程读取传入消息的 dll。使用 Blueprint 类导入虚幻引擎,因为我无法获取传入消息。我计划在 dll 中有一个事件,我会将事件处理程序放入虚幻引擎代码中。
你能帮帮我吗,这可能吗?如果它是如何使用它的?
我正在尝试类似enter link description here
【问题讨论】:
标签: c++ events unreal-engine4 eventhandler
在 dll 代码中
EventCallback OnEvent = NULL;
DLL_EXPORT void WINAPI SetEventCallback(EventCallback func)
{
OnEvent = func;
}
DLL_EXPORT void WINAPI FireEvent()
{
if (OnEvent)
OnEvent();
}
在虚幻引擎代码中
typedef void(*_getSetEventCallback)(EventCallback);
_getSetEventCallback m_getSetEventCallbackFromDll=NULL;
void CALLBACK HandleEvent()
{
FString fstringVar = "Triggered by Event in dll";
UE_LOG(LogTemp, Warning, TEXT("%s"), fstringVar);
}
void UVectorDll::importSetEventCallback()
{
if (c_dllHandle != NULL)
{
FString procName = "SetEventCallback"; // Needs to be the exact name of the DLL method.
m_getSetEventCallbackFromDll = (_getSetEventCallback)FPlatformProcess::GetDllExport(c_dllHandle, *procName);
m_getSetEventCallbackFromDll(HandleEvent);
}
}
FireEvent 可以通过 dll 或虚幻引擎完成
【讨论】: