Is it possible to know if an Asset will be Packaged from the editor?

Hello!

We have a Plug-in module that creates asset and we would like to know if it would be possible to know in code if a given asset will be packed in the final game.

For example, we have Asset A that is in a packaged Level A, Asset B in not packaged Level B and Asset C that is referenced in an ini file. In that case the results would be:

Asset A: true because Level A is packaged

Asset B: false because Level B is not packaged

Asset C: true because it is in an ini file

Thank You!

Hello!

There is unfortunately no easy answer to your questions as it depends on the Asset being part of the reference chain of other assets that end up being cooked. Some things that you can affect the inclusion\exclusion of assets in a package:

  • By default, all of the project’s content will be cooked and included in the package
  • The packaging settings have a few properties that will affect what will get cooked:
    • MapsToCook: Adding to this array will result on only cooking the listed levels and the folder in DirectoriesToAlwaysCook
    • DirectoriesToAlwaysCook: those will be part of any cook
    • DirectoriesToNeverCook: Those folder will never be cooked and referencing assets in there will result in broken references.
  • The Cook commandlet has a few way to inject Maps to the cook. Injecting a single Map will always restrict the cook to its referenced assets.
    • -Maps=Level1+Level2+…
    • -MAPINISECTION=SectionA+SectionB+…
      • The sections can be defined in DefaultEditor.ini and look like this:
[SectionA]
Map=Level1
 
[SectionA]
Map=Level2
Map=Level3
Map=Level4

Those are the most commons ways to decide what levels and folders are part of a cook. There are a few other arguments to the Cook commandlet: https://dev.epicgames.com/documentation/en\-us/unreal\-engine/cooking\-content\-in\-unreal\-engine?application\_version\=5\.6

In lots of cases, you can probably rely on UProjectPackagingSettings::MapsToCook and UProjectPackagingSettings::DirectoriesToAlwaysCook but that will break of the user is injecting maps in other ways. You can retrieve the default object using the following:

const UProjectPackagingSettings* const PackagingSettings = GetDefault<UProjectPackagingSettings>();

Regards,

Martin