Might anyone know why including “UnrealEd” in Private or Public dependencies in Game.build.cs causes an UnrealBuildTool failure?
If you create a C++ ShooterGame project and add that dependency it will fail to package. Not sure if there is another dependency to include or a missing .dll somewhere?
You will need to create a separate editor-only module if you plan on using stuff from UnrealEd in your game. Add the dependency to that module instead of your runtime module, and don’t include it when cooking.
Michael, thank you very much for the quick response!
I’ve setup a new module that encapsulates my editor code and I am able to get it to compile. However when I package I still run into the same issue, I thought the ‘Type’:‘Editor’ would take care of the ‘don’t include it when cooking’ part of your suggestion but I’m guessing that is not enough.
Might anyone know how can I make it so that my new editor module is not included when I package the game?
Make sure you aren’t depending on the module in your Target.cs when doing a game build in your SetupBinaries. You’d want to do something like this if you have to link it into the game in an editor build:
if (UEBuildConfiguration.bBuildEditor)
{
OutExtraModuleNames.Add("QAGameEditor");
}
Hmm so if I add my ‘ShooterGameEditor’ module to either the Private/PublicDependencyModuleNames then I can #include “ShooterGameEditor.h” where I want to access the editor code and everything works great in the editor. However, when packaging the game I get an UnrealBuildTool failure as previously noted.
If I remove the ‘ShooterGameEditor’ module from Private/PublicDependencyModuleNames and instead include it
if (UEBuildConfiguration.bBuildEditor)
{
OutExtraModuleNames.Add(“ShooterGameEditor”);
}
within the respective Target.cs files this causes the compiler to complain of a ‘fatal error C1083: Cannot open include file: ‘ShooterGameEditor.h’: No such file or directory’
So I’m not really sure how I can solve this, I’ve followed these two approaches and a combination of both to no avail :\
Use #if WITH_EDITOR around code you want to exclude from runtime builds, but ideally your runtime code doesn’t depend on your editor code (only the other way around). What is your specific use case?
I was able to resolve this by checking if the build was an editor build before including ‘UnrealEd’ dependency and wrapping the code that depends on it with #if WITH_EDITOR
if (UEBuildConfiguration.bBuildEditor)//we only want this to be included for editor builds but not packaged builds
{
PublicDependencyModuleNames.AddRange(
new string] {
"UnrealEd",
}
);
}