第3期(1):UE4插件编写技巧(2)
1. 在编译打包你的UE4插件时,包含插件中的其他文件夹和文件为了在打包你的UE4插件时(这里指的是只编译打包插件,而不是指的是打包你的虚幻工程项目),包含你在该插件中添加的其他文件夹和文件,你需要在你的插件文件夹中包含一个“Config”文件夹,在该“Config”文件夹中包含一个“FilterPlugin.ini”文件。该文件的内容类似于:
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
;
; Examples:
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll
/README.txt
/Extras/...
/Binaries/ThirdParty/*.dll
你可以采用下图的方法打包你的插件(点击下图中的“Package...”按钮):
参考:
【1】:Plugins
【2】: Marketing FAQ
2. 在编译打包你的UE4工程项目时,包含你的插件中的第三方DLL文件
为了在打包你的UE4工程项目时,让UE4自动把你的插件中的第三方(ThirdParty)DLL文件一起打包,你需要在插件模块的对应“*.Build.cs”文件中添加如下代码:
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(ThirdPartyDLLDirectory, "QRCodeSDK.dll")));
完整例子如下所示:
/*
*Copyright (c) 2016-2017 YeHaike(841660657@qq.com).
*All rights reserved.
*@ Date : 2017/05/11
*
*/
using System;
using System.IO;
using UnrealBuildTool;
public class QRCodeUE4Library : ModuleRules
{
public QRCodeUE4Library(ReadOnlyTargetRules Target) : base(Target)
{
Type = ModuleType.External;
string PluginDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", ".."));
string ThirdPartyDLLDirectory = Path.Combine(PluginDirectory, "Binaries\\ThirdParty", Path.GetFileName(ModuleDirectory), Target.Platform.ToString());
Console.WriteLine("ThirdPartyDLLDirectory: " + ThirdPartyDLLDirectory);
if (Target.Platform == UnrealTargetPlatform.Win64)
{
// Add the import library
PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "QRCodeSDK\\QRCodeSDK\\x64", "Release"));
// Console.WriteLine(Path.Combine(ModuleDirectory, "QRCodeSDK\\QRCodeSDK\\x64", "Release"));
PublicAdditionalLibraries.Add("QRCodeSDK.lib");
// Delay-load the DLL, so we can load it from the right place first
PublicDelayLoadDLLs.Add("QRCodeSDK.dll");
// List of files which this module depends on at runtime. These files will be staged along with the target.
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(ThirdPartyDLLDirectory, "QRCodeSDK.dll")));
}
else if (Target.Platform == UnrealTargetPlatform.Mac)
{
PublicDelayLoadDLLs.Add(Path.Combine(ModuleDirectory, "Mac", "Release", "libQRCodeSDK.dylib"));
}
}
}
<hr/>3. 提交UE4插件到虚幻商城上,插件Demo的“.uproject”中,需要添加如下代码:
&#34;Plugins&#34;: [
{
&#34;Name&#34;: &#34;HiSQLite3&#34;,
&#34;Enabled&#34;: true,
&#34;MarketplaceURL&#34;: &#34;com.epicgames.launcher://ue/marketplace/content/c8c0f3c46971495b8a8d400ec8627caa&#34;
}
]
插件Demo的“.uproject”文件可以参考如下内容:
{
&#34;FileVersion&#34;: 3,
&#34;EngineAssociation&#34;: &#34;4.18&#34;,
&#34;Category&#34;: &#34;&#34;,
&#34;Description&#34;: &#34;&#34;,
&#34;Modules&#34;: [
{
&#34;Name&#34;: &#34;HiSQLite3_UE4Demo&#34;,
&#34;Type&#34;: &#34;Runtime&#34;,
&#34;LoadingPhase&#34;: &#34;Default&#34;,
&#34;AdditionalDependencies&#34;: [
&#34;Engine&#34;
]
}
],
&#34;Plugins&#34;: [
{
&#34;Name&#34;: &#34;HiSQLite3&#34;,
&#34;Enabled&#34;: true,
&#34;MarketplaceURL&#34;: &#34;com.epicgames.launcher://ue/marketplace/content/c8c0f3c46971495b8a8d400ec8627caa&#34;
}
]
}
-----------------------------------------------------------------------------------------------
更新列表:
[*]YeHaike(2017-12-06):添加《1. 在你的UE4插件中包含其他文件夹和文件》;
[*]YeHaike(2017-12-06):添加《2. 在编译打包你的UE4工程项目时,包含你的插件中的第三方DLL文件》;
[*]YeHaike(2018-01-27):添加《3. 提交UE4插件到虚幻商城上,插件Demo的“.uproject”中,需要添加如下代码》
----------------------------------------------------------------------------------------------- 解决了问题.....
页:
[1]