I have a webgl project that contains a scene where you can select a level and launch it.
The level itself is loaded from an assetbundle using WWW.LoadFromCacheOrDownload(uri,0), where zero is the arbitrary version of the bundle.
The problem is when I make changes to the level and create newer bundle, the old cached bundle is still being loaded because the version number is hardcoded to 0 inside the selector scene.
Is there any way I can always ensure that the latest bundle version is downloaded or loaded from cache ? instead of incrementing bundle version and building a new selector scene each time I update the bundle?
You could also use a manifest (text file / json) stored in the Resources folder of the game (will be copied in the build shared-assets as well) with a token/version for the build and add the assetbundle name and variant.
First creating the serializable class GameManifest and add a property like public string GameToken; or checksum to keep the build and the bundles only available for eachother and no other builds/bundles with different checksums. Serialize/export the game manifest to file (i recommend Json) a.e “Assets/Resources/manifest.json”.
When loading the bundles, first load the bundle with the game manifest file and load the asset from the bundle as the TextAsset type and get the text from it, deserializing the text through Json (again), and then use Resources.LoadAsset<TextAsset>("path"); to get it from the build and then you just compare those. If their checksums ain’t loyal (had to do it) / aren’t equal, the build and bundle aren’t from the same build version.