I’m experiencing big trouble with this.
I could setup my game with assetbundles for webplayer and all is working fine, I can download the assets, instantiate in the proper order and all works, but then I tried to figure out what happens when something fails.
So I forced an error just changing the url for the assets to an unreachable one (just added some random letters to the assetbundle file name), and here starts the nightmare.
First I’ll explain what’s happening and later some things I found on the way. I used for this a modified version of the InstantiateResource from the AssetBundles example project.
When I play in the editor, the script try to download the asset, because that’s impossible due to changed name, it drops an error “Resolving host timed out: nemdrive.com”, no problem with this and works as expected.
Then I placed a button to retry the download when this happens, and here is the problem, when I press the button the player stops and drops this error:
Failed to load asset bundle
UnityEngine.WWW:get_assetBundle()
As far as I know, it is trying to extract the assets from the download (download is my var name for WWW object), but the download did not completed, even it must be null because the file could not be downloaded, What’s happening here?. It seems that after first attempt to make the download it thinks there is a download already in place and tries to extract something.
I tried in every way possible, any code combination and searched in every Unity related sites for an answer but I could’t find any clue.
And some weird things I saw:
1- When you make an attemto to download with the WWW class, the errors come after the download is made, and during the download progress the error is null, so you don’t know if there is a problem or not.
2- That means that, even when the download is impossible, after several seconds download.isDone goes truth.
3- Even download.progress equals to 1.
How the hell isDone can be truth and progress can be 1 if the download is not possible?
How can I tell the system that there is nothing downloaded to retry and avoid that the script tries to extract assets from the empty download?
In the retry button I used all kinds of stuff:
download.Dispose();
download = null;
but I saw no difference with this. And of course, in the InstantiateResource.js from the AssetBundle example, the progress is shown “if (download.error == null)”, but that means nothing because the error comes later.
This is very annoying and a big problem for me, or maybe I missed something. Please help.