How can I cook assets for only certain platforms?

How can I cook certain assets for only certain platforms?

I am making a cross-platform game with VR support and use the MetaXR plugin. I also support platforms that don’t allow MetaXR or are not supported, like Linux, iOS, Mac, and even more specifically LinuxServers.

Instead of accessing MetaXR functions directly in my pawn or primary game blueprints, I have isolated all functions to standalone blueprints that are spawned and accessed only via soft class references on supported platforms to avoid hard references and a cook.

I initially had the assets in the main project and tried to find a way to isolate them, but I further theorized a plugin is best, but I am still stuck.

I currently have all of these assets in the content directory of a plugin that strictly is for this purpose with no other code.

I have the plugin Supported Platforms and PlatformAllowList to have Windows and Android (Quest), which is what I need. It packages the plugin, but not the content within it.

If I add the plugin’s content folder to AdditionalAssetDirectoriesToCook, the soft class references work, but this causes platforms without MetaXR support to fail, like Linux. This is expected behavior.

If I remove the plugin’s content folder from AdditionalAssetDirectoriesToCook, the unsupported platforms package fine, and the plugin is included within the desired supported platforms, but since the assets are not hard referenced anywhere, they are skipped, and the soft class references fail.

Is there a way to achieve a sorts of “AdditionalAssetDirectoriesToCook” for a specific platform, or another way to force the cooking of certain assets for specific platforms only?

I am really stuck on this and trying as many potential solutions as I can manage.

Any help would be greatly appreciated.

Thank you,

-Brandon

Hey @RealAero !

You can modify your .ini files for platform.
For example : Config/Android/AndroidEngine.ini

You can add a file with the next config:

[/Script/UnrealEd.ProjectPackagingSettings]
+DirectoriesToAlwaysCook=(Path="/Game/AndroidAssets")  ; Only cook this folder for Android

Anyway I don’t recommend this approach. Can generate silent errors hard to find.
Try better to setup a data assets with the specific asset for the platform and only reference to those ones if is required.

Hey! Thank you for your response!

I tried this, and unfortunately, it doesn’t seem to work.