- Home /
How do you package/retrieve Asset Bundle Dependencies
We have hundreds of assets that are all bundled individually as separate asset bundles. Some assets or levels may use 1 or more of those asset bundles. Here is an example:
Assets:
1001 - [gun.fbx, gun.png, gun.mat]
1002 - [bullet.fbx, bullet.png, bullet.mat]
1003 - [gloves.fbx, gloves.png, gloves.mat]
1004 - [shoes.fbx, shoes.png, shoes.mat]
1005 - [1001, 1002, space_level.fbx, space_level.png, space_level.mat]
1006 - [1003, 1004, character_model.fbx, character_model.png, character_model.mat]
When I bundle asset 1006, for instance, asset bundles 1003 & 1004 are listed as dependencies, as expected. Although in the manifest, the full absolute path to that asset bundle on my hard drive is listed.
When I go to load asset bundle 1006, none of the objects from asset bundles 1003 or 1004 are included.
So my question is: How do I load the dependent assets (1003 & 1004) in theoretical asset bundle 1006?
Am I responsible for downloading each of the dependent asset bundles and unbundling them first? What if I have hundreds of dependencies - that doesn't seem like an efficient way to download content to my user's devices.
Is there a way to build asset bundle 1006 so that it simply includes all of the parts from asset bundles 1003 and 1004?
This is how I'm building the asset bundles at the moment:
BuildPipeline.BuildAssetBundles ("Assets/AssetBundles/", buildMap, BuildAssetBundleOptions.None, BuildTarget.TargetPlatform);
Any help would be appreciated.
Hello, did you ever get a solution for this? I have the same issue of absolute path for dependencies.
@Fabien-LG Unfortunately we never found a solution. We reached out directly to Unity and offered to pay for premium support in order to figure out the solution or work with them to create one. Unfortunately, the cheapest they were willing to go for premium support was 6k a month with a 6 month contract, which sounded to us, unreasonable.
Our solution, ins$$anonymous$$d, was to manage this on our server - keeping intricate track of our own dependencies. When a particular asset is requested, our custom bundler code pings our server and first downloads and correctly unpacks all required bundles before downloading and unbundling the required bundle.
The disadvantages of this approach may be obvious and include tons of custom code and tracking, plus, in some cases, a TON of individual downloads for the user rather than just one.
The advantage of this approach is that our asset system can be a little bit clever in how and when it downloads assets. For instance, even though in my example above, asset 1006 requires 5 things including two other asset bundles, we may be able to get away downloading a few of them piecemeal while the user is idle, allowing a bit more flexibility.
To further explain the advantage, imagine a user needs to download a largish 100mb level consisting of 20+ individual assets. Traditionally, they would have to have their device on and chugging through that download. That might be undesirable and the download may fail because the user doesn't want to wait or for any number of reasons. With our system, we can download each piece, one by one, making the entire download easier to manage.
I don't know that the advantages outweigh the disadvantages, but it works for us. I, or course, wish that Unity would provide a better way for us to understand and manage Asset Bundles. $$anonymous$$aybe better documentation is all that is needed - I've read it all.