Hi, guys
First of all I would like to appreciate the whole job with asset bundles during these years, many things have been improved a lot. However I think many useful things are getting lost from the asset bundles legacy system.
When I talk about this legacy system I am referring to the very old legacy functions that even though are marked as obsolete are still working today. We have been working with this legacy option for 5 years so far because they were added into one of our projects (still being updated) long ago when it was the only option available. The system had a lot of issues but we were able to create a workflow where dealing with all this was almost transparent
Recently we have been taking a look into the new system, and more specifically Addressables and even though all the improvements are really welcome we are missing a lot of features… I’d like to show you what we have been doing first so you can understand our problem easier.
1. Asset bundle Creation
We created all our builds using one script called “CustomBuilds”. This script manages a lot of things for properly delivering the different builds we needed. It is also the script responsible of the creation of our Asset bundles using BuildPipeline.PushAssetDependencies, BuildPipeline.PopAssetDependencies, BuildPipeline.BuildAssetBundle and BuildPipeline.BuildPlayer. So at the end of our build process we have a code similar to this
BuildPipeline.PushAssetDependencies();
foreach (string assetBundle in BundlesList) {
BuildPipeline.BuildAssetBundle(…);
}
BuildPipeline.BuildPlayer(…);
BuildPipeline.PopAssetDependencies();
Basically, every call to BuildAssetBundle was putting some assets into the specific asset bundle but also was removing them from the list of assets to include in the next asset bundles and the final build. You could create dependencies between assetbundles this way. There were already plugins to manage these dependencies and also to explore and create the asset bundles (we were using one of these available plugins on the store to manage the assetBundles content but in the end we were creating them ourselves).
AssetBundles dependencies are not possible now with the new system. If you add an asset to a bundle and also to the build then this asset is duplicated. There is no way to create a “reference” to an asset included in an asset bundle, imagine a material not included in any bundle referencing a texture inside a bundle for instance. You might think this is a good thing since you remove this annoying dependence but this also breaks what we consider the most useful part of the bundle system (see below)
2. Asset bundle loading
There were two ways to load assets from a bundle: direct access and indirect access.
- In direct access we called AssetBundle.LoadAsset similar to when you call Resources.Load. This function is not marked as obsolete (yet) so we can still use it. There is also AssetBundle.LoadAssetAssynch that we never used basically because we never needed it and also because it complicated things a lot. Interestingly this is the approach the new Addresables system is taking: assynch loading. You may have already guessed by the posts of other people in the forums that this is not a good idea, we need non-assynch functions
- Indirect access is more interesting. This way of using asset bundles was poorly documented which I think is the main reason why most people were not using it (and probably didn’t even know about its existance). At some point of our application we just opened the bundles calling WWW.LoadFromCacheOrDownload (note this is marked as obsolete) from a local uri usually pointing to StreamingAssets folder or Application.persistentDataPath where we had previously downloaded them. After this call all asset dependencies were magically resolved and we didn’t have to change a single line of code. In the previous example where there is a material on the build referencing a texture on an AssetBundle if we used this material after opening the bundle it was working. No extra lines of code loading the texture from the bundle was needed. Also, we never closed any of the opened bundles because the memory impact was minimum (opening the bundle was not loading all its content into memory) and asset references were managed the same way any other asset not included in bundles was, no extra ref count were needed (another big problem of the new system)
Indirect access required to work with some limitations on the asset bundles. The kind of stuff we put on a bundle were basically textures, sounds and FBXs. We never included any scripts or shaders to avoid annoying issues that were very known back in the day. For this same reason we were never including prefabs or materials because they could potentially lead to the inclusion of scripts or shaders.
But the main benefit of indirect access was that we didn’t need to change any line of code when moving stuff to bundles. This was important for us since we included Assetbundles after being working in the project for a couple of years (imagine changing all our loading stuff to assynch calls). We needed to open the bundles before using any resource from them and we had to download everything manually but that was ok. The approach now seems to make this transparent but this was never a problem for us. We clearly prefer to manage the download of assets (because we know the app and we know when we are going to need to do it) than having to move all our loading stuff to an assynch approach, besides it is very common to move to a loading screen where all needed assets bundles are being loaded in the background. It is impossible to make this transparent
Not sure if I have properly explained it but, our biggest concern now that we are starting a new project is that we are losing a lot of benefits we had and we are getting a lot of issues that we never had to deal with.
So now that I have explained our workflow, here are the things I wanted to ask:
- What is the main reason to deprecate WWW.LoadFromCacheOrDownload? Why not fix all the issues it had instead.
- Why are you guys deprecating assetbundles dependencies? I understand they create some problems but let us deal with them, the benefits are higher