- Home /
Asset bundle not getting loaded from cache
In my case instead of simple assetBundles I am dealing with Streamed Scene Asset Bundle.
In my Splash Screen Scene (Before getting in to the actual game) I download the asset bundle using www.loadfromcacheordownload() ....it works fine.
IEnumerator DownloadAssetBundle(string abname, string url, int version)
{
www = WWW.LoadFromCacheOrDownload(url, version);
while (!www.isDone && www.error == null)
{
Debug.Log("downloaded " + (www.progress * 100).ToString() + "%..." + "Asset Name : "+abname);
yield return null;
}
if ((www.error != null && !www.isDone))
{
throw new System.Exception("WWW download had an error:" + www.error);
}
else
{
yield return www;
}
}
Now when my game starts... I ask the user to select from available levels (that were downloaded as asset bundles)....
When I load one of these level ... I again use www.loadfromcacheordownload() .... so this time asset bundle is supposed to be loaded from cache ...
IEnumerator CreateLevelStringAndLoadLevel(int levelNumber)
{
string levelToLoad = "Level_" + levelNumber;
// We have an array of assetbundle info in our jChapterNode, so "chapterNumber - 1" refers to the track number of corresponding assetbundle
string url = GetChapterURL(levelNumber);
int version = GetChapterVersion(levelNumber);
www = WWW.LoadFromCacheOrDownload(url, version); // should be loading from cache
//yield return WaitForLoading();
if(www.error != null)
throw new UnityException("Error while downloading AssetBundle : " + www.error);
if (Caching.IsVersionCached(url, version))
bundle = www.assetBundle;
async = Application.LoadLevelAsync(levelToLoad); // Level that is to loaded has name Level_1, Level_2....so on...!!
while (!async.isDone)
{
uiSlider.value = async.progress; // Show the progress bar increasing with 'async.progress'
yield return null;
}
}
but my game crashes at this point (on devices) ....and while play testing in editor ... the editor crashes and I am not getting any other leads. No error no exception....nothing...!!
Where can the problem be ... Please help...!!
Cheers....
Thanks in Advance...!!
Something more that I found.... When I try to debug using $$anonymous$$onodevelop's Breakpoints...Unity still crashes but I get these errors
The funny bits are First ....This thing was working like a cheese cake and one not-so-fine day it just stopped... Second.... that using the exact same code and exact same Streamed Scene AssetBundle in a fresh (new) project things work good.... without any issue.
Can I get any lead on this where could the problem be....!! Please please please help.... Its been more than 2-3 weeks for me getting stuck in this...
Ok now ... it is not getting crashed ... but the following error is co$$anonymous$$g...
Level 'Chapter_1' (-1) couldn't be loaded because it has not been added to the build settings. To add a level to the build settings use the menu File->Build Settings...
@whydoidoit .... i have gone through many of your tutorials and posts... I am sure you have some thing that may help he here...Please ... !!
Answer by ajketan · Dec 01, 2014 at 08:09 AM
Eventually I found out that there was nothing wrong with the code that I used.... It was the assetbundle that was causing issues for me.... apparently there was a GameObject that was having a singleton class attached to it...and this GameObject was not getting used. So I removed it and everything was normal.
I am yet to figure out what is the relation between that GameObject being in my scene and my AssetBundle not getting loaded. Please if anyone is aware of that .... kindly enlighten me...!!
Cheers
Your answer
![](https://koobas.hobune.stream/wayback/20220613155846im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to import the object from server to unity 2 Answers
Saving an AssetBundle decompressed 0 Answers
www doesn't work on ios Unity5.3.4 0 Answers
BuildPipeline.BuildPlayer - Download scenes without adding them to build menu 1 Answer
Can I download a single asset file through WWW class instead of the assetbundle? 0 Answers