Get Hash from streamed scene asset bundle


I’m currently trying to export and import assetBundle that contains a scene. I’m trying to access the hash in order to use WWW.LoadFromCacheOrDownload (String url, Hash128 hash) as checking if I should download a new bundle on the server or not.

Unfortunately, I can’t get the assetBundleManifest from the assetBundle, which should give me the hash I need to compare the versions of the bundles in cache or online.

//Download assetBundle via WWW
WWW wwwManifest = new WWW (path);
yield return wwwManifest;

//get the manifest
AssetBundle manifestBundle = wwwManifest.assetBundle;
AssetBundleManifest manifest = manifestBundle.LoadAsset ("AssetBundleManifest") as AssetBundleManifest; //Fails because my bundle is a scene
//Get The hash
Hash128 hash = manifest.GetAssetBundleHash (bundleName);
//Get the last bundle from hash
WWW www = WWW.LoadFromCacheOrDownload (path, hash))

Apparently, I can’t use LoadAsset () on a streamed scene assetBundle. Maybe I’m doing something wrong. I just want to load the newest scene bundle, if I use WWW.LoadFromCacheOrDownload (String url, int version), it always get the one from the cache.

Can someone help me out with this? Or at least explains me how it exactly works, because I’m a bit lost and I don’t understand everything about assetbundles.

Thank you,

Still didn’t figure out about Hash but I get it to work I think with versions.

As I understand version is stored with the bundle in the cache when downloaded with:
WWW.LoadFromCacheOrDownload (String url, int version)

The version you give has to be incremental on each new version of the assetbundle on server during download (and not during export…). My workaround:

Export the dateTime in a text file when exporting the assetbundle. This will be the way to check if the assetBundle is more recent than the one in cache. On each Download, you’ll store the dateTime localy (playerPrefs for instance), so you’ll have the dateTime on server and on cache for comparison. Then you’ll have to store the version integer as well, which will be incremented at each new download. This version number will be set as parameter into the WWW.LoadFromCacheOrDownload (String url, int version) function. This way, the version number is incremental and has the lastest number of the assetBundle version.

I’m still looking for answers about the Hash for sceneAssetBundle which seems to be a better way to do so.