WWW www = WWW.LoadFromCacheOrDownload(fileUrl, version);
yield return www;
if (!string.IsNullOrEmpty(www.error)) {
Debug.LogError("error:" + www.url + " " + www.error);
yield break;
}
GameObject go = (GameObject)GameObject.Instantiate(www.assetBundle.mainAsset);
www.assetBundle.Unload(false);
www.Dispose();
yield return www;
if (!string.IsNullOrEmpty(www.error)) {
Debug.LogError("error:" + www.url + " " + www.error);
yield break;
}
GameObject go = (GameObject)GameObject.Instantiate(www.assetBundle.mainAsset);
www.assetBundle.Unload(false);
www.Dispose();
上面的代码调用的同时(同一帧前后)调用Application.LoadLevel("SomeLevel"),会导致yield return www;后面的代码不被调用,因为这些代码所处的对象在装载新Level时已经被销毁,最终造成在再次加载这个URL时出现:
Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle