I'm trying to load a remote image for a texture but in case the URL is not correct, no internet conection, etc, I want to use a local backup texture. He's the code I'm using to acomplish this, the problem is that if the image url is correct but it's not a jpg or a png the error seems to stay at null and I get the red question mark. Code (csharp): remoteTexture = new WWW(remoteTextureURL); yield remoteTexture; if(remoteTexture.error) { useRemoteTexture = false; finalTexture = texture; } else { useRemoteTexture = true; finalTexture = remoteTexture.texture; } How do I change this in order to use the backup texture in this case?
The only way I've found to handle this is something like Code (csharp): if (remoteTexture.error || (remoteTexture.texture.width == 8 remoteTexture.texture.height == 8)) { Since the question mark thingy is a 8x8 texture. Granted, this is a hack (what if you really want to use a valid 8x8 texture for some reason, or what if UT changes the size of the question mark?), so hopefully someone has a better idea.... --Eric
Thanks Eric, that's quite a hack but it works for me now, I hope they change WWW.error so it reports non supported image formats as errors.
I use kinda the same hack and its really ugly simply put it means that one cant use 8x8 textures. I have made a feature request to UT that the function be made to return null instead of the texture. Sometimes making things "Just work" is taking the error auto fixing to far. I do belive that the developers who makes the download textures script should handle what happens if they get a 404 error and not unity, although admittedly it is convenient sometimes to see the question mark, but i would much rather code it my self and have a null value instead.