Asset Bundle dependcies when including scenes
I've been working on getting asset bundles up and running, which by now seems to work. I do have some questions about memory usage in the scenario we're implementing though.
The approach we're taking involves including all our gameplay scenes in an AssetBundle (possibly several), so that we can later change the scenes and then have them be updated through new AssetBundles. So what we do is to tag all the scenes as being part of an AssetBundle, then remove the scenes from the Build Settings list and load them from the bundle instead. All menu scenes, loader scenes, etc. will remain in the Build Settings and get included in the build. This seems to work just fine, but I'm worried about asset dependencies and multiple instances of various assets being generated.
First of all, removing all the scenes from the Build Settings also means that none of the stuff they reference will get included in the build - including engine code. We can get around this, even if it's a bit cumbersome, by making instances of the engine components we need in one of the scenes we do include in the Build Settings. It just doesn't seem elegant, but it's doable. We can of course also choose to not strip engine code in Player Settings, but we don't really want to do that.
Where it becomes troublesome is if we need to keep track of everything we use in these scenes, to make sure nothing ends up in multiple Asset Bundles. It's okay if we only use one Asset Bundle for all our scenes, in which case we "just" have to make sure nothing is used both in our in game scenes and menus. But if we want to split up our gameplay levels into several Asset Bundles, we'd risk getting a lot of dependency issues, since many of the scenes will reference the same assets. The documentation state that in order to avoid multiple instances of an asset when using Asset Bundles, you have to explicitly include that asset in an Asset Bundle. So in order to avoid duplicates, we'd have to make sure that all our assets are explicitly part of an Asset Bundle?
I hope my explanation makes sense and that someone can offer a little bit of insight to this issue.
Answer by Heino · Feb 15, 2016 at 03:09 PM
I'm taking the liberty of 'bumping' this issue, in hope of some replies. We want to be able to make changes to the game after launch with as little an impact on the user's end as possible. That means we'd like to break up our assets into as many asset bundles as possible. Ideally, one scene would mean one asset bundle, so that if we make changes to one scene, the user will not have to download all the other scenes. Problem is that if we put each scene in different asset bundles, each bundle will contain all the assets this scene needs too, which is of course very inefficient.
So I guess that means we'll have to manually put all the assets referenced in the scenes into asset bundles, but how do we figure out which assets to load for which scenes at runtime? I don't want to load in textures, meshes, materials, etc. that are not needed in a given scene, simply because it's referenced by some other scene. Isn't there some way to intelligently determine what assets are used and load them in when needed. Unity does this normally, deleting and loading resources as needed, but all this functionality seem to be missing with asset bundles?