要将源码中的非运行时模块移植到Runtime下使用,个人理解就是一个解决编译报错的过程,先将目标模块复制到项目的source目录内,然后修改模块文件夹名称,修改模块.build.cs与文件夹名称保持一致
修改build.cs内的类名 ,每个模块都要修改
// Copyright Epic Games, Inc. All Rights Reserved.using UnrealBuildTool;public class RTDesktopPlatform : ModuleRules
{public RTDesktopPlatform(ReadOnlyTargetRules Target) : base(Target){PrivateIncludePaths.Add("RTDesktopPlatform/Private");PrivateDependencyModuleNames.AddRange(new string[] {"Core","ApplicationCore","Json"});if (Target.IsInPlatformGroup(UnrealPlatformGroup.Linux)){PrivateIncludePathModuleNames.AddRange(new string[] {"RTSlateFileDialogs",});DynamicallyLoadedModuleNames.Add("RTSlateFileDialogs");AddEngineThirdPartyPrivateStaticDependencies(Target, "SDL2");}UnsafeTypeCastWarningLevel = WarningLevel.Error;}
}
// Copyright Epic Games, Inc. All Rights Reserved.using UnrealBuildTool;public class RTSlateFileDialogs : ModuleRules
{public RTSlateFileDialogs(ReadOnlyTargetRules Target) : base(Target){PrivateIncludePaths.AddRange(new []{"RTSlateFileDialogs/Private",});PrivateDependencyModuleNames.AddRange(new string[] {"Core","CoreUObject","InputCore","Slate","SlateCore","RTDirectoryWatcher",});PrivateIncludePathModuleNames.Add("TargetPlatform");}
}
// Copyright Epic Games, Inc. All Rights Reserved.using UnrealBuildTool;public class RTDirectoryWatcher : ModuleRules
{public RTDirectoryWatcher(ReadOnlyTargetRules Target) : base(Target){PrivateIncludePaths.Add("RTDirectoryWatcher/Private");PrivateDependencyModuleNames.Add("Core");UnsafeTypeCastWarningLevel = WarningLevel.Error;}
}
刷新项目后修改项目.uproject文件,添加启动模块
{"FileVersion": 3,"EngineAssociation": "{415CA20E-4C6F-969C-0B60-4DBEE9818054}","Category": "","Description": "","Modules": [{"Name": "MyRunImpFBX","Type": "Runtime","LoadingPhase": "Default","AdditionalDependencies": ["Engine"]},{"Name": "RTDesktopPlatform","Type": "Runtime","LoadingPhase": "Default"},{"Name": "RTSlateFileDialogs","Type": "Runtime","LoadingPhase": "Default"},{"Name": "RTDirectoryWatcher","Type": "Runtime","LoadingPhase": "Default"}],"Plugins": [{"Name": "ModelingToolsEditorMode","Enabled": true,"TargetAllowList": ["Editor"]}]
}
在项目build.cs中添加依赖项
// Copyright Epic Games, Inc. All Rights Reserved.using UnrealBuildTool;public class MyRunImpFBX : ModuleRules
{public MyRunImpFBX(ReadOnlyTargetRules Target) : base(Target){PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;PublicDependencyModuleNames.AddRange(new string[]{"Core","CoreUObject","Engine","InputCore","EnhancedInput","HeadMountedDisplay","Slate","SlateCore","UMG","RTDesktopPlatform",});PrivateDependencyModuleNames.AddRange(new string[] { });}
}
此时编译会有很多错误,后面就是解决报错的过程,过程中删除了报错的DesktopPlatform_API,打包后模块丢失,修改了模块的IMPLEMENT_MODULE( FDesktopPlatformModule, RTDesktopPlatform );后解决问题,