I am trying to load a scene from an AssetBundle(unity web player)the bundle is also cached.
When i run it for the first time everything runs absolutely perfect and the new scene is loaded, but when i quit the game once and run the build again it gives the error
the level (level name) could not be loaded as it has not been added to the build settings.
Here is the code
Code to Build Asset Bundle
//Creating Asset Bundles For web Player
@MenuItem ("Assets/Build AssetBundle Factory Area %u")
static function CreateSceneBundle1(){
// list of the levels to be streamed
var levels : String[] = ["Assets/1-Scenes/AbandonedDay.unity",
"Assets/1-Scenes/AbandonedSunset.unity",
"Assets/1-Scenes/AbandonedNight.unity"];
var path = EditorUtility.SaveFilePanel ("Save Resource", "", "factoryarea", "unity3d");
if (path.Length != 0)
{
BuildPipeline.BuildStreamedSceneAssetBundle( levels,path, BuildTarget.WebPlayer);
}
}
It looks like the problem here is related to the caching - not how it works, but what it does & doesn’t cache.
What it will cache is the bundle itself - you’ve got that portion right, and can avoid downloading it again. However, just because the bundle is cached, you still have to load the assets from it again!
Fortunately, you’ve already got both sides of the download covered with the:
bundleWWW = WWW.LoadFromCacheOrDownload(url,1);
So, ultimately, you can still do the cache check, but your LoadCurrentLevel function should be called regardless of whether the bundle is cached or not.
I was getting the same problem where unity was throwing error “Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle”. I was loading asset bundles at different stages of level but when I try to restart the level and try to load the asset bundle again I got the same error stated above. Then I tried saving the asset bundles in a list and trying to clear the list at level restart but that doesn’t solved the problem. I even tried Caching.CleanCache() to remove any data from the memory but no use.
I was saving the assets bundles on the disk after downloading and loading them again from the disk after level load.
}* using bundle.Unload(false) after instantiating the gameObject have done the trick. Not sure wether its mandatory to unload the bundle after you have instantiated it. But this has solved my problem.
if i made a game and exported all its assets inside asset builder and uploaded to web , than can i delete all my asset from the game as i am going to download all asset from net later and run a scene from that assets .