ue4 调用Dll
来源:互联网 发布:网络侦查技术方法 编辑:程序博客网 时间:2024/06/10 18:33
UE4使用Dll
Part1. 创建和编译Dll
VS中创建Visual C++ > Win32 Console Application 工程模板,选择Dll,并勾上”Empty Project”。
在SolutionExplorer里选中工程,右键Add>New Item,选择C++ File
在新建的文件里输入测试代码:
extern "C" __declspec(dllexport) float getCircleArea(float radius)
{
return 3.1416 * (radius*radius);
}
菜单Project>xxxProperties,Configuration Manager,把所有的关于位设置的都设置为x64
保存后Build Solution。
Part2 拷贝到引擎目录
在工程中找到x64文件夹下的dll. 复制到引擎Plugins目录,可以自己新建一个子文件夹放置自定义的插件。
这里放在D:\Program Files (x86)\Epic Games\4.13\Engine\Plugins\KenPlugins
Part3 UE4工程中加入Dll
创建一个C++ UE4工程
File>New C++ Class…
选择Blueprint Function Library作为父类
在生成的.h文件的类定义中加入如下定义:
public: // Blueprint accessible method. UFUNCTION(BlueprintCallable, Category = "Ken Libraries") static float getCircleArea(float radius);在.cpp中加入以下代码typedef float(*_getCircleArea)(float radius); // Declare the DLL function.float UMyBlueprintFunctionLibrary::getCircleArea(float radius){ FString filePath = FPaths::Combine(*FPaths::EnginePluginsDir(), TEXT("KenPlugins/"), TEXT("SampleDll.dll")); // Concatenate the plugins folder and the DLL file. if (FPaths::FileExists(filePath)) { void *DLLHandle; DLLHandle = FPlatformProcess::GetDllHandle(*filePath); // Retrieve the DLL. if (DLLHandle != NULL) { _getCircleArea DLLgetCircleArea = NULL; // Local DLL function pointer. FString procName = "getCircleArea"; // The exact name of the DLL function. DLLgetCircleArea = (_getCircleArea)FPlatformProcess::GetDllExport(DLLHandle, *procName); // Export the DLL function. if (DLLgetCircleArea != NULL) { float out = DLLgetCircleArea(radius); // Call the DLL function, with arguments corresponding to the signature and return type of the function. return out; // return to UE } } } return 1.00f;}
其中UMyBlueprintFunctionLibrary 是类的名称,*FPaths::EnginePluginsDir()是引擎的插件目录, TEXT("KenPlugins/")是自定义的文件夹, TEXT("SampleDll.dll")是dll名称
Part4 蓝图中调用dll
在蓝图的Ken Libraries分类中找到 get circle radius节点即可使用
- UE4调用dll
- ue4 调用Dll
- UE4中调用DLL并提供蓝图接口
- ue4 rpc调用不起作用
- UE4调用摄像头
- [UE4]蓝图调用c++
- UE4 远程调用函数
- ue4-Network相关-rpc调用
- UE4 C++调用蓝图方法
- UE4 Sequencer的事件调用
- UE4跨模块调用示例
- UE4启动丢失VCRUNTIME140.dll错误解决
- dll调用
- 调用DLL
- 调用DLL
- DLL调用
- DLL调用
- dll调用
- 将博客搬至简书
- 正则表达式必会知识点
- STS(Sping Tool Suite)安装后启动失败集合-yellowcong
- 开启我的第一篇博客——noip2017,I'am coming
- spring怎么自动添加消息处理器的? <mvc:annotation-driven />
- ue4 调用Dll
- python: py2下 中文 的 文件读写 及 打印
- js表单校验代码(供参考)
- SpringMVC注解@initbinder解决类型转换问题
- 关于react native初始化项目后,返回error code500问题
- Android- instanceof操作符
- Python画矩形和圆形
- wcsstr
- github多个账户配置ssh key使用