There is a discrepancy in how Unreal Engine (UE) handles the cooking process for assets in DirectoriesToNeverCook
when comparing the version from the Launcher with the version built from Source Code.
- In UE from the Launcher, the engine does not cook assets from
DirectoriesToNeverCook
as well as assets that are referenced by anything within these directories. - In UE built from Source Code, the engine does not cook only the assets directly under
DirectoriesToNeverCook
. However, assets referenced by other assets fromDirectoriesToNeverCook
are still cooked, even if no other references to those assets exist anywhere in the project.
Example:
I have the following project file structure:
- MainLevel: Contains a soft reference to SimpleSublevel, which has hard references to Actor_A and Actor_B.
- MainLevel is set as the only level to include in the packaged build (via Project Settings).
- The folder containing SimpleSublevel and Actor_A is marked as DirectoriesToNeverCook.
and following reference structure:
and relevant project settings:
Launcher Behavior (UE 5.4.4 or 5.1.1): When using UE from the Launcher, only MainLevel is cooked, and the cooker log shows:
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MySublevels/SimpleSublevel, Instigator: { SoftDependency: /Game/MainLevel } -> Rejected NeverCook
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MySublevels/SimpleSublevel -> Rejected NeverCook
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MainLevel, Instigator: { PackagingSettingsMapToCook }
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MainLevel
Source Code Behavior (UE 5.4.4 or 5.1.1): When using UE built from Source Code with no changes, Actor_B is also cooked, even though it is only referenced by SimpleSublevel, which itself is not cooked because it belongs to a folder marked as DirectoriesToNeverCook. Actor_A, however, is excluded as expected. The cook log shows:
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MySublevels/SimpleSublevel, Instigator: { SoftDependency: /Game/MainLevel } -> Rejected NeverCook
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MySublevels/SimpleSublevel -> Rejected NeverCook
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MySublevels/Actor_A, Instigator: { Unsolicited: /Game/MySublevels/SimpleSublevel } -> Rejected NeverCook
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MySublevels/Actor_A -> Rejected NeverCook
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MainLevel, Instigator: { PackagingSettingsMapToCook }
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/MainLevel
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/Actor_B, Instigator: { Unsolicited: /Game/MySublevels/SimpleSublevel }
UATHelper: Cooking (Windows): LogCook: Display: Cooking /Game/Actor_B
Question:
Why is the cook behavior different between the Launcher and Source Code versions? Which of these is the “correct” behavior?
I prefer the first behavior (Launcher), as it allows for a convenient setup in our project. We need to configure different sublevels for desktop and mobile platforms, and being able to exclude unused assets (and their dependencies) by simply adding their folders to DirectoriesToNeverCook would be ideal. This method would allow us to rely on UE’s dependency tracking mechanism instead of manually tracking unused assets and adding them one by one to DefaultPakFileRules, bExcludeFromPaks, or Files.