[Solved] Error caching assetbundles

When downloading assetbundles using the following code from the unity docs, I receive an error.

while (!Caching.ready)
yield return null;

var www = [WWW.LoadFromCacheOrDownload(url](http://WWW.LoadFromCacheOrDownload(url), 0);
yield return www;
if (string.IsNullOrEmpty(www.error)) //string returns as null thus causes an error
{
Debug.Log(www.error);:wink: // these two lines print the errors seen below
yield return www.error;
}
else
{
ContinueFromDownloadModels(www.assetBundle);:wink: //Function that then loads assets from the bundle
}

The errors received are “Unable to move cache folder ‘C:/Users/name/AppData/LocalLow/Unity/WebPlayer/Cache/Temp/409646… etc’ to ‘C:/Users/name/AppData/LocalLow/Unity/WebPlayer/Cache/Name_Name/b6589fc6… etc’: destination exists”

and “You are trying to load data from a www stream which had the following error when downloading.
Couldn’t move cache data ‘C:/Users/name/AppData/LocalLow/Unity/WebPlayer/Cache/Temp/409646… etc’ into place ‘C:/Users/name/AppData/LocalLow/Unity/WebPlayer/Cache/Zendeavor_Zendeavor/b6589… etc’ when caching AssetBundle”. Both errors are the same, just worded differently.

I have tried this on a different PC to see if it was a error local to my machine but I receive the same thing, if anyone knows a fix I will be very grateful.

Thanks in advance.

Update: Turns out you cant have any assetbundles with the same name, which is what caused this error. If you also receive this error make sure all your assetbundles have unique names.

2 Likes

I know it’s an old question but I had similar issue. It turns out that I created 2 concurrent requests for the same asset bundle. the first request checked that the asset was not cached yet and asked the server for it. then the second request checked that the asset was not cached yet and also asked the server for it. but then the first request returns the asset and caches it. after that the second request request returns the asset BUT IT’S ALREADY CACHED. Throw!

1 Like

For future readers, that might experience this issue with Unity Addressables, this seems to work for me:

while (!Caching.ready)
    yield return null;

before attempting to load any addressables, meaning I put this as the very first thing the app does

5 Likes

Future reader here, much appreciated!

this is very helpful for me! thank you!