目录
(1)平台 Target.Platform
类型定义文件:Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs
UnrealTargetPlatform.Win32 ||
UnrealTargetPlatform.Win64 ||
UnrealTargetPlatform.HoloLens ||
UnrealTargetPlatform.Mac ||
UnrealTargetPlatform.XboxOne ||
UnrealTargetPlatform.PS4 || …
(2)模块依赖
PublicDependencyModuleNames
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
"Media",
"MediaAssets",
}
);
PrivateDependencyModuleNames
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"Projects",
"RenderCore",
"RHI",
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
(3)添加包含路径
PublicIncludePaths.Add(MyPublicIncludePath);
PrivateIncludePaths.Add(MyPrivateIncludePath);
PublicIncludePaths.AddRange( new string[] {
MyPublicIncludePath1,
MyPublicIncludePathN
});
PrivateIncludePaths.AddRange(new string[] {
MyPrivateIncludePath1,
MyPrivateIncludePathN
});
(3.1)私有包含路径模块名
PrivateIncludePathModuleNames.AddRange(
new string[] {
"ModuleName1",
"ModuleName2",
}
);
(4)添加静态依赖库
PublicAdditionalLibraries.Add("完整路径/库名.lib");
(5)添加动态库
//(5.1)确定打包后,动态库存放的位置 -- 插件库中的位置
RuntimeDependencies.Add(new RuntimeDependency("完整路径/静态库名.dll"));
//using System.IO;
//遍历文件夹添加运行时依赖
if (Directory.Exists(PluginDirectory))
{
foreach (string Plugin in Directory.EnumerateFiles(插件路径, "*.*", SearchOption.AllDirectories))
{
RuntimeDependencies.Add(Path.Combine(插件路径, Plugin));
}
}
//(5.2)确定打包后,动态库存放的位置 -- 程序运行时的目录
RuntimeDependencies.Add("$(BinaryOutputDir)/动态库名.dll", "完整路径/动态库名.dll");
//(5.3)定义 PublicDefinitions
if (Target.bCompileNavmeshSegmentLinks)
{
PublicDefinitions.Add("WITH_NAVMESH_SEGMENT_LINKS=1");
}
else
{
PublicDefinitions.Add("WITH_NAVMESH_SEGMENT_LINKS=0");
}
(6)异常/警告
bEnableExceptions = true;
bEnableUndefinedIdentifierWarnings = false;
/* PublicLibraryPaths : 已弃用*/
/* ModuleDirectory : 当前模块路径 */
(7)问题/报错
1)启动提示
Plugin ‘***’ failed to load because module '***' could not be load. There may be an operating system error or the module may not be properly set up.
原因:启动相关引用未找到;
处理:添加相关引用或手动拷贝相关文件到运行目录(工程目录\Binaries\Win64);