Hi
Our game requires a system that downloads any new content from the net and uses it in game. I am using LoadFromCacheOrDownload() for it.
It works fine … it downloads my content and all is good till here.
Now ideally when once the content is downloaded it should not download again. But that is happening with me. On my PC I can see the cached assetBundle getting deleted from the cache folder when I run the game again and then it downloads again. This also happens on my iOS Devices.
How do I restrict that ?
here is the code that I am using…
private IEnumerator load(string url, int version)
{
// wait for the caching system to be ready
while (!Caching.ready)
yield return null;
// load AssetBundle file from Cache if it exists with the same version or download and store it in the cache
if(Caching.IsVersionCached(url, 1) == false)
{
www = WWW.LoadFromCacheOrDownload(url, version);
yield return www;
Debug.Log("Downloading again");
}
else
{
Debug.Log("Downloading again is not required....already in cache");
}
Debug.Log(" Loaded ");
if (www.error != null)
throw new Exception("WWW download had an error: " + www.error);
AssetBundle assetBundle = www.assetBundle;
AssetBundleRequest request = assetBundle.LoadAsync ("myObject", typeof(GameObject));
yield return request;
if(request.isDone == false)
{
//request.allowSceneActivation = true;
}
else
{
GameObject myObj = assetBundle.mainAsset as GameObject;
Instantiate(myObj);
//request.allowSceneActivation = false;
}
// Unload the AssetBundles compressed contents to conserve memory
assetBundle.Unload(false);
}