背景
UE4工程编译中,遇到下面报错:
2>UnrealBuildTool: Error : Unable to instantiate module 'UnrealEd': Unable to instantiate UnrealEd module for non-editor targets.
(referenced via Target -> CrossPlatformAutoTest.Build.cs -> MyGameGameplay.Build.cs -> AutomatedTesting.Build.cs)
分析与解决方案
这行报错位于:
// Engine\Source\Editor\UnrealEd\UnrealEd.Build.cs
public class UnrealEd : ModuleRules
{
public UnrealEd(ReadOnlyTargetRules Target) : base(Target)
{
if(Target.Type != TargetType.Editor)
{
throw new BuildException("Unable to instantiate UnrealEd module for non-editor targets.");
}
本身 UnrealEd 的含义就是 Editor 的意思,因此 无法在 non-editor 的目标中使用。
然后从报错去追踪 AutomatedTesting.Build.cs ,可以看到下面引用:
if (Target.Type == TargetRules.TargetType.Editor || Target.Type== TargetRules.TargetType.Client)
{
PrivateDependencyModuleNames.AddRange(new string[] { "UnrealEd", });
}
把 Client 给去掉就好了。