Using TargetBuildEnvironment.Unique causes Shader path issue and incorrect Content merging

I’m using  BuildEnvironment = TargetBuildEnvironment.Unique;

The reason for this is that I modify stack size and unless I use TargetBuildEnvironment.Unique I get this error:

throw new BuildException("{0} modifies the value of {1}. This is not allowed, as {0} has build products in common with {2}.\nRemove the modified setting or change {0} to use a unique build environment by setting 'BuildEnvironment = TargetBuildEnvironment.Unique;' in the {3} constructor.", ThisTargetName, Field.Name, BaseTargetName, ThisRules.GetType().Name);

This causes me 2 issues, a solution to any would be much appreciated:

  1. I have to move my game project folder in the game engine folder or the following line in ShaderCore.cpp fails:

    check(FPaths::DirectoryExists(RealShaderDirectory));

because FPlatformProcess::BaseDir() returns a different value when using TargetBuildEnvironment.Unique.
I assume this happens because UBT changes the RootDirectory from the Engine directory to the project directory.

This can be kinda-fixed by moving the game project folder to the UnrealEngine root folder, but then this causes issue 2) below:

  1. If I move my game project folder to the root UE engine folder my game Content gets messed up: it doesn’t show under the “Game” content anymore:
    instead it gets pulled into “Engine Content” and I cannot even open it since it cannot finds any assets.

Any idea if what I’m trying to do with 2) is even possible?

Any idea how to fix 1) or 2)?

Any idea how I can otherwise set stack size without having to set TargetBuildEnvironment.Unique?

1 Like