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 打包C++项目到win32平台报错 could not find mspdbcore.dll
解决方法: 将Visual Studio中相应系统(如32位对应x86.64位对应x64)下的 ms.*.dll 等一系列文件拷贝到 C:\Windows\System32\ 路径下.踩坑:不能只拷贝 ...
- win10环境下ue4使用游戏手柄输入
忙里偷闲,趁着源码编译需要好久的时间,把这篇博客补上,来说说怎么在win10环境中,ue4使用游戏手柄输入,也就是gamepad输入. 1.我用的手柄是rapoo v10 这款手柄,连接无线USB之后 ...
- ue4 模块的构建和加载
ue4的代码是模块的形式来组织 在源码层面,一个包含*.build.cs的目录就是一个模块 这个目录里的文件在编译后都会被链接在一起,比如一个静态库lib,或者一个动态库dll. 不管是哪种形式,都需 ...
- ue4 build configuration的解释
ue4的build系统,继承并发展了3代的一如既往的复杂.. 一.每个configuration由两部份组成:[(性能)模式]+[(内容)组成] 模式有:Debug,DebugGame,Develop ...
- UE4/Unity3D中同时捕获多高清摄像头的高效插件
本文主要讲实现过程的一些坑. 先说下要实现的目标,主要功能在UE4/Unity中都要用,能同时捕获多个摄像头,并且捕获的图片要达到1080p25桢上,并且需要经过复杂的图片处理后丢给UE4/Unity ...
- UE4游戏开发基础命令
在个人的Unrealengine账户中关联自己的GitHub账户成功之后,就可以访问UE4引擎的源码了. git clone -b release https://github.com/EpicGam ...
- dll加密工具
Virbox Protector Standalone 加壳工具可直接对dll文件进行加壳,防止代码反编译,更安全,更方便. 产品简介 Virbox Protector Standalone提供了强大 ...
- UE4杂记
一些学习UE4时的笔记,转载请注明出处. ☆ UE4逻辑 Actor 是由 AActor 类派生而来的类实例:能被放入游戏世界场景的所有游戏性对象的基础类.对象是继承自 UObject 类的类实例:虚 ...
随机推荐
- Android Framework中Thread类
Thread类是Android为线程操作而做的一个封装.代码在Thread.cpp中,其中还封装了一些与线程同步相关的类. Thread类 Thread类的构造函数中的有一个canCallJava T ...
- eclipse 背景绿豆沙颜色
General -> Editors -> Text Editors -> Appearance color options -> Background color 色调:85 ...
- ecshop 实现“精品、新品、热销”板块出现选项卡效果的方法
最近做一个网络商城,直接使用ecshop的免费模板,懒得重新做,ecshop建站多日了,一直想在主页的板块中建网页选项卡鼠标经过自动切换效果,百度搜索这方面的内容也没找到合适的,今天一实验,成功了,所 ...
- Python笔记(二十九)_模块
模块 在Python中,一个.py文件就是一个模块 if __name__ == '__main__':所有模块都有一个 __name__ 属性,__name__ 的值取决于如何应用模块 run当前文 ...
- 【SD系列】SAP 退货冲账过账成本更新
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP 退货冲账过账成本更新 前 ...
- pyAudioAnalysis-audioFeatureExtraction 错误纠正
1. TypeError: mfccInitFilterBanks() takes 2 positional arguments but 7 were given The issue In the f ...
- js json中的时间转换格式
//根据json中的日期格式,转换成yyyy-mm-dd HH:mm:ss function ChangeDateFormat(cellval) { var date = new Date(parse ...
- JavaSE编码试题强化练习3
1.给20块钱买可乐,每瓶可乐3块钱,喝完之后退瓶子可以换回1块钱,问最多可以喝到多少瓶可乐. public class TestCirculation { public static void ma ...
- 【译】Redux 还是 Mobx,让我来解决你的困惑!
原文地址:Redux or MobX: An attempt to dissolve the Confusion 原文作者:rwieruch 我在去年大量的使用了 Redux,但我最近都在使用 Mob ...
- [APIO2019] 奇怪装置
$solution:$ 问题其实就是求两个式子的循环节. 钦定 $t\mod B=0$且 $(t\neq 0)$,其 $t$ 为循环节. 则将 $1$ 式拆开得 $\frac{t\times (B+1 ...