0
votes

This is probably a very niche question, but what are the specific differences between an asset bundle and a cached bundle for the asset bundle system that Unity 4 used? I'm curious how cached files differ to asset bundles and what, if any, different properties change from both types of files? I.E. What happens to asset bundles when they are cached through WWW.LoadFromCacheOrDownload?

Unity unfortunately doesn't have this process documented as the open source code calls an internal function called INTERNAL_CALL_WWW(this, url, ref hash, crc), which is given the instance of WWW, the string of the URL, a Hash128 and a UINT called crc with a default value of 0. (Referenced decompiled 5.3.2p2 code, 2017+ code is on the official Unity GitHub, but seems to differ from Unity 2015 code).

The Unity 2017 code leads to the private extern static IntPtr CreateCached(DownloadHandlerAssetBundle obj, string url, string name, Hash128 hash, uint crc); external method, which isn't documented either.

Furthermore, what actually happens when an asset bundle is cached so that the engine can recognise the file is in cache and doesn't need to be downloaded? Is it just simply that it searches for the hashed name in the cache, or does it do something more intricate?

Frostrix

1

1 Answers

0
votes

I can clearly see the difference in size between created asset bundles (those to put on server to download later) and cached asset bundles (those downloaded once at runtime and stored to the device). On Windows you can find them at %appdata%/Local Low/Unity/company+name_of_app. Cached versions are typically less compressed so the app can load them faster, while those stored on the server are more compressed so it takes less bandwidth to download. The content should be the same, but compressed using different methods. See this docs page for more details.