How to detect if it's editor build in Build.cs?

In my old project I had this bit of code in its Build.cs:

    if (UEBuildConfiguration.bBuildEditor == true)
    {
        PublicDependencyModuleNames.AddRange(
            new string[] {
                "UnrealEd",
            }
        );

The goal is to load UnrealEd only if I’m compiling an Editor build configuration (Development Editor, etc).

However when I try to switch to 4.19, I get an error saying:

error CS0103: The name 'UEBuildConfiguration' does not exist in the current context

So how do you do it in 4.19?

4 Likes

Try this:

if (Target.bBuildEditor)
{
	PrivateDependencyModuleNames.Add("UnrealEd");
}
6 Likes

Worked. Thanks!

Even when question is already answered, i want to point, that better to use this:

if (Target.Type == TargetRules.TargetType.Editor) {...}

1 Like

Thanks for the suggestion, lun

Could you explain why it’s better?

2 Likes