Detecting Texture2D.LoadImage failure

I noticed that Texture2D.LoadImage will return true regardless of whether the data passed to it contains valid image data. The resulting texture is a small red question-mark, but there doesn’t seem to be a way to actually check that LoadImage failed.

The same happens with WWW: I downloaded some JSON data, expecting WWW.texture to be null, but it wasn’t - and using that texture gave me the same question mark texture as before. Again, there’s apparently no way to check if the texture is valid.

Is there any way at all to check if some binary data contains valid image data without having to resort to external libraries?

Unity only supports Jpeg and png, both of which have magic headers (JFIF and PNG). Otherwise, compare size then pixels to known failed image.

I agree, it’s pretty poor.

That would imply using “is readeable” which makes a copy of the picture in computer memory.

The questionmark texture is 8 8 tex2d width and height so if it is that then you can say it returned isDone with an 404 of some kind.

Other thing for me to focus on is keeping the pictures on the HDD because i go rapidly over 1gb memory with these textures.