UnrealEd included in build despite Editor module

Hi there,

I’m currently working in a small example project to test some ideas I have about some editor code for my main project. One of the things I wanted to focus on was make sure everything I was doing is buildable, and that I had established the right process for maintaining editor code.

I’ve created a separate editor module with my editor specific code in it, and the build.cs for my editor includes UnrealEd, however when I build my project I’m getting a raft of errors relating to it, the only way I can get it to avoid these errors is by simply commenting out my editor module in my project’s target.cs. I would’ve assumed “if(bBuildEditor)” to be false in development builds, but I’m now guessing it’s not? If that, then, is the case, what is the query I should be using to ensure my editor is not included even in development builds of the game, but still in development editor?

Here’s an example of the kind of errors I’m getting for the build:

U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public\EdGraph/EdGraphNodeUtils.h(31): error C2039: 'GetGraph': is not a member of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Classes\EdGraph/EdGraphNode.h(171): note: see declaration of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public\EdGraph/EdGraphNodeUtils.h(31): error C2039: 'GetSchema': is not a member of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Classes\EdGraph/EdGraphNode.h(171): note: see declaration of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public\EdGraph/EdGraphNodeUtils.h(31): error C2227: left of '->IsCacheVisualizationOutOfDate' must point to class/struct/union/generic type
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public\EdGraph/EdGraphNodeUtils.h(54): error C2039: 'GetGraph': is not a member of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Classes\EdGraph/EdGraphNode.h(171): note: see declaration of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public\EdGraph/EdGraphNodeUtils.h(57): error C2039: 'GetSchema': is not a member of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Classes\EdGraph/EdGraphNode.h(171): note: see declaration of 'UEdGraphNode'
U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public\EdGraph/EdGraphNodeUtils.h(57): error C2227: left of '->GetCurrentVisualizationCacheID' must point to class/struct/union/generic type
U:\UnrealEngine-4.17.2\Engine\Source\Editor\BlueprintGraph\Classes\K2Node.h(180): error C3668: 'UK2Node::ReconstructNode': method with override specifier 'override' did not override any base class methods
U:\UnrealEngine-4.17.2\Engine\Source\Editor\BlueprintGraph\Classes\K2Node.h(181): error C3668: 'UK2Node::GetNodeTitleColor': method with override specifier 'override' did not override any base class methods

for context here’s my projects files:

Uproject:

{
	"FileVersion": 3,
	"EngineAssociation": "{92C5AC8E-4175-8E02-07FE-01BC4C19F361}",
	"Category": "",
	"Description": "",
	"Modules": [
		{
			"Name": "NoteTest",
			"Type": "Runtime",
			"LoadingPhase": "Default",
			"AdditionalDependencies": [
				"Engine"
			]
		},
		{
			"Name": "NoteTestEditor",
			"Type": "Editor",
			"LoadingPhase": "PostEngineInit"
		}
	]
}

Project Target.cs

using UnrealBuildTool;
using System.Collections.Generic;

public class NoteTestTarget : TargetRules
{
	public NoteTestTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Game;
		ExtraModuleNames.Add("NoteTest");
		
		if (UEBuildConfiguration.bBuildEditor)
		{
			ExtraModuleNames.AddRange(new string[]{"NoteTestEditor"});
		}
	}
}

Editor target.cs

using UnrealBuildTool;
using System.Collections.Generic;

public class NoteTestEditorTarget : TargetRules
{
	public NoteTestEditorTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Editor;
		ExtraModuleNames.AddRange(new string[]{"NoteTest", "NoteTestEditor"});
	}
}

Project Build.cs:

using UnrealBuildTool;

public class NoteTest : ModuleRules
{
	public NoteTest(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
	}
}

Editor Build.cs

using UnrealBuildTool;

public class NoteTestEditor : ModuleRules
{
	public NoteTestEditor(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] {
            "NoteTest",
            "Core",
            "InputCore"});

        PrivateDependencyModuleNames.AddRange(new string[] {
            "CoreUObject",
            "Engine",
			"AssetTools",
            "DetailCustomizations",
            "EditorStyle",
            "PropertyEditor",
            "Slate",
            "SlateCore",
            "MainFrame",
			"UnrealEd"});
		
		PublicIncludePaths.AddRange(new string[]{"NoteTestEditor/Public"});

		PrivateIncludePaths.AddRange(new string[]{
            "NoteTestEditor/Private",
            "Editor/DetailCustomizations/Private",
            "EditorStyle",
            "PropertyEditor"});
    }
}

I don’t believe any of the files here are setup in an incorrect manner, though I may be wrong in that assumption.

A related query I have is, what is the distinction between AdditionalDependencies in UProject and adding items in the build.cs? I was previously adding a lot more in AdditionalDependencies, but realised it wasn’t necessary, but I can’t find anything from Google that explains the distinction.

look here GitHub - GSAero/Creating-an-Editor-Module: The source code to the article https://wiki.unrealengine.com/Creating_an_Editor_Module

Hey, thanks for the response, sorry, I’m not quite sure what you mean by this. I too followed this tutorial, and I had a little look at the code in your repository and it’s quite similar to my own. Is there something you’re referring to that I’m missing? Is there a section in the tutorial or in your source code that would answer either of my queries?

  • What exactly bBuildWithEditor does, and if the code IS included with development packaged projects, what query to use instead

  • The difference between additional dependencies in UProject and including items in the build.cs

If I uncomment out the “UnrealEd” line in your editor build.cs I get the same error as my own, so is your answer that I should simply comment out includes? That’s a process that seems a little too manual, and I’d rather avoid if possible.

Hello, I’m having the exact same issue. Were you able to figure this out yet? I can’t determine where the editor is being included that causes these compile errors. Mine are identical to yours and I have mine setup in the same way.

I BELIEVE (although I haven’t tested this in a while now as I’ve been worrying about other things) that you should be able to check the target type for whether or not you include the editor:

		Type = TargetType.Game;
		ExtraModuleNames.Add("MyGame");
		
		if (Type == UnrealBuildTool.TargetType.Editor)
		{
			ExtraModuleNames.AddRange(new string[]{"MyGameEditor"});
		}

Though off the top of my head I think there were still some issues with this so I think I ended up going manual and getting around the issue by stripping out the editor code whenever we make a build, something I’m really not happy about, but it’s not an issue I have the time to investigate at the moment sadly. I can confirm that bBuildEditor will still be true when doing a build (development at the very least) even though #WITH_EDITOR should be false in this scenario.

UnrealEd? “U:\UnrealEngine-4.17.2\Engine\Source\Runtime\Engine\Public”

This is Runtime Engine code. I have the same exact failure and was hoping you found the problem?

For me this turned out to be a Module Dependency in the build.cs of a runtime module on an editor module. You will not find an include to comment out, as the .h file is passed to the build tool on the command line.

What dependency was missing in your build file?

It was not missing. We have an Editor only module. And someone had ADDED it to the primary Game module. PrivateDependency list. Editor needs to know what the game code does. But not the other way around. We have a bunch of #if WITH_EDITOR code chunks that rely on the Editor Module. So adding code in the build CS to only add that if its building an editor.

public class MyClass : ModuleRules
{
	public MyClass (ReadOnlyTargetRules Target) : base(Target)
	{

        PublicDependencyModuleNames.AddRange(new string[] 
        { "Core"
        , "CoreUObject"
        , "Engine"
        , "InputCore"
        });

        PrivateDependencyModuleNames.AddRange(new string[] 
        {
        });

        if (Target.bBuildEditor) // <--- this is needed so we only include the EditorModules in an Editor Build.
        {
            PrivateDependencyModuleNames.AddRange(new string[]
            {
                "UnrealEd"
            ,   "MyEditorModule"  // <--- this is needed to call the editor functions when building an editor.  BUt should not be part of the final game.
            });

            PrivateIncludePaths.AddRange(new string[]
            {
                "MyEditorModule",
            });
        }
    }
}

If this is the issue you are having, then the editor builds fine, and you get those weird errors only when building the standalone game.

Thank you! It was a little bit different in my case, but you helped me understand the problem:

In GameName.Target.cs file I didn’t need to include the Editor Module.

using UnrealBuildTool;
using System.Collections.Generic;

public class GameNameTarget : TargetRules
{
	public GameNameTarget(TargetInfo Target) : base(Target)
    {
		Type = TargetType.Game;

        ExtraModuleNames.AddRange(new string[] { "GameName" });

        ExtraModuleNames.Add("GameNameEditor"); // <----- Had removed this line
    }
}

I had to remove that line *******

yeah they could catch this in the build tool. All they have to do is check if the module being depended on is an editor module or not. Would be a much better error message than the weird compiler errors.

Glad you got it fixed.