- Home /
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?
Answer by Waz · Jun 30, 2011 at 12:52 PM
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.
Answer by drudiverse · Dec 13, 2015 at 12:21 PM
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.
Your answer
Follow this Question
Related Questions
cant get Texture2D.LoadImage() to work 0 Answers
How to load with Texture2D.LoadImage? -1 Answers
iOS crashing on Texture2D LoadImage 1 Answer