unreal engine 中 C++ dll 的触发事件
Triggering event of C++ dll in unreal engine
我正在尝试使用 dll,它将带有 thread.Importing 的传入消息读取到带有蓝图 class 的 unreal engine 中,因为我无法获取传入消息。我计划在 dll 中创建一个事件,我将为此在 unreal engine 代码中放置事件处理程序。
你能帮帮我吗,这可能吗?如果是如何使用它?
我正在尝试这样的事情enter link description here
在dll代码中
EventCallback OnEvent = NULL;
DLL_EXPORT void WINAPI SetEventCallback(EventCallback func)
{
OnEvent = func;
}
DLL_EXPORT void WINAPI FireEvent()
{
if (OnEvent)
OnEvent();
}
在Unreal engine代码中
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 或从 Unreal Engine
我正在尝试使用 dll,它将带有 thread.Importing 的传入消息读取到带有蓝图 class 的 unreal engine 中,因为我无法获取传入消息。我计划在 dll 中创建一个事件,我将为此在 unreal engine 代码中放置事件处理程序。
你能帮帮我吗,这可能吗?如果是如何使用它?
我正在尝试这样的事情enter link description here
在dll代码中
EventCallback OnEvent = NULL;
DLL_EXPORT void WINAPI SetEventCallback(EventCallback func)
{
OnEvent = func;
}
DLL_EXPORT void WINAPI FireEvent()
{
if (OnEvent)
OnEvent();
}
在Unreal engine代码中
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 或从 Unreal Engine