Asset Bundle Dependencies

Hi,

I am a little confused right now how to correctly split up my content into asset bundles. We are working on a puzzle game with many different levels. Each level will be its own asset bundle.

Some of the content of these levels will be identical across all levels, specifically the GUI with all of its icons and textures. I want this content to be installed directly with the base game.

So I was planning on taking the .unity file of each level and assigning it to its own asset bundle. If I do this, I believe that Unity will collect all dependencies (among others, the GUI with its icons) and also put that into the bundle. So how can I have this stuff be part of the base game instead? Well, technically I think it would be in the base game, but it would also be in every single bundle. I want it to be ONLY in the base game and have all asset bundle scenes use these assets from the base game.

You should probably assign the common stuff - GUI, icons and whatever else is needed across all level, into its own asset bundle (name that “Common” for example).

This asset bundle can be delivered directly with the game package itself (not as a separate download). All other asset bundles (each for its own level) will reference assets that are contained in the shared (common) asset bundle. This bundle will be automatically loaded when the game is started so it’s accessible to all levels that need it.

Thank you very much, I see what you’re saying. Just one more question, how can I make sure that this common asset bundle is included in the APK?

You can either place that under a Resources folder, or under StreamingAssets.
Both will get included into your game build.

You can also use a custom text file format and serialize your levels to avoid using asset bundles.

I see, thank you so much for your help!

That sounds like an excellent workflow, however in the case of our game every level has its own custom meshes and textures, which is why we use asset bundles to split the data up into lots of smaller downloads.

1 Like

I have a followup question now. Our levels will all have a prefab that contains the GUI and a custom script. The parameters for this custom script will be individually set for each level.
If I now put this entire prefab into its own asset bundle as discussed, will all levels correctly refer to that same prefab, even though some of the parameters on their version of the prefab are different?

The reason why this is important is so that we can later update that one prefab with new functionality in the base installation, and all DLC levels will automatically use that new prefab (but retaining their changed parameters), rather than needing to be updated themselves.

This should be fine - all levels should be marked as their own asset bundle, and the referenced prefab should be placed in its own asset bundle.

In this setup, all scenes will contain a reference to that prefab which should be loaded from its own asset bundle. All scenes will save their own values for this particular prefab so you should be good to go.

1 Like

Ok perfect, thank you so much for confirming that this should work!