UE4 引用

目录

(1)平台  Target.Platform

(2)模块依赖

(3)添加包含路径

(4)添加静态依赖库

(5)添加动态库

(6)异常/警告

(7)问题/报错


(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);

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值