Maybe there’s something fundamental I’ve misunderstood about AssetBundles, but am I correct in assuming that AssetBundles is something that you should be able to change and update after release of your game, without having to change game code? If so, I don’t understand the WWW class’ LoadFromCacheOrDownload. This one takes a version number as input and only if this version number has changed or no cached version of the object exists does it download the package.
However this means that if we need to get a new version of an AssetBundle downloaded, we’d have to change the version number in LoadFromCacheOrDownload in our game code, which kind of defeats the purpose. What we want is to be able to change content of an AssetBundle to i.e. include new textures or new settings for objects, without having to create an update for our app, which the users would then have to download from the app store.
Basically the functionality we’re after should download the AssetBundle if no cached version exists or the AssetBundle has changed on the server, independent on what version number is passed to LoadFromCacheOrDownload. How would I go about implementing such a feature? We don’t want to re-download the entire package every time, since it could potentially be rather large.
So as you said, the version numbering only works for forcing different client builds to look for bundles cached with different version numbers. If your game is using a server, you could hook up this version number to a value you can change on the server and force updates that way, but that’s perhaps not the best way to do it, but i think something like this is the only choice you have if you are using Unity 4.x.
The problem with what you want is: if the only information the client has are the bundles themselves, it would have to download them to know if they have changed or not, which defeats the whole purpose of caching.
The new bundle system in Unity 5 has a solution for this though. LoadFromCacheOrDownload in Unity 5 has a new overload that takes in a Hash128 instead of a version. When you build the bundles, a tiny “manifest bundle” is created and it in turn contains the hashes of all the actual bundles that you built.
The hash works exactly like the version number in the sense that if you download a bundle with a certain hash, if a previous download is found with the same hash the bundle will be fetched from cache, else it will be downloaded. But the important thing here is that you never cache the manifest bundle, so when you upload a new set of bundles with a new manifest bundle, the client can read the changed hashes from the manifest bundle and if you use them for LoadFromCacheOrDownload, all changed (and only the changed) asset bundles will be re-downloaded.
I strongly encourage everyone to watch this video ant the code examples related to it. The stuff I’m talking about happens starting at about 30 mins in.
You could do the same thing Unity 4 / version number by for example making a small text file with the version numbers for each bundle in it and making the client load that first in order to know what version to use for the LoadFromCacheOrDownload calls. The system is just a bit more robust in Unity 5 and it automatically handles unchanged/changed bundles.
I am interested in an update to this question in light of developments in AssetBundles. @Heino 's question is the same as my current dilema. Could you please help me with updated links or best approach to this issue @NoseKills . Thanks