简体   繁体   English

虚幻引擎中C++ dll的触发事件

[英]Triggering event of C++ dll in unreal engine

I am trying to use dll which reads incoming messages with a thread.Importing into unreal engine with Blueprint class, As I can't get the incoming messages.我正在尝试使用 dll,它通过线程读取传入消息。使用蓝图 class 导入虚幻引擎,因为我无法获取传入消息。 I am planning to have a event in the dll for which I'll put event handler in unreal engine code.我计划在 dll 中进行一个事件,我会将事件处理程序放入虚幻引擎代码中。

Can you please help me, Is this possible If it is how to work with it?你能帮我吗,这可能吗?如果它是如何使用它的?

I am trying something like this enter link description here我正在尝试这样的事情在此处输入链接描述

In dll code在 dll 代码

EventCallback   OnEvent = NULL;
DLL_EXPORT void  WINAPI SetEventCallback(EventCallback func)
{
    OnEvent = func;
}
DLL_EXPORT void WINAPI FireEvent()
{
    if (OnEvent)
        OnEvent();
}

In Unreal engine code在虚幻引擎代码中

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 can be done by dll or from Unreal Engine FireEvent 可以由 dll 或虚幻引擎完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM