|
According to the Unity Script Reference WWW.LoadImageIntoTexture page, "if the data is not a valid image, the generated texture will be a small image of a question mark." Is there any way to change the question mark or at least get a return from the error, so that I could replace the texture manually? Thank You. -Sixakoo
(comments are locked)
|
|
No. The most you can do is check the image against a known-failed image (like file://nosuchimage).
(comments are locked)
|
|
Warwick Allison's suggestion (of comparing to a "known-failed" image) is probably the best, most future-proof option. Another possibility which is a little simpler, but will fail if unity ever changes the appearance of the default "error" texture, is to convert your texture into an array of bytes using EncodeToPNG(), and compare the array to a predetermined array representing the PNG-encoded version of the default "error" texture. I have implemented an example of Warwick Allison's suggestion, plus the other technique I suggest, here: http://www.unifycommunity.com/wiki/index.php?title=TextureBogusExtensions I implemented it as a C# extension method on the Texture class, which may be overkill. But people keep asking this question on the #unity3d IRC chat channel, so I figured I'd put the code out there.
(comments are locked)
|

Possibly:
I suspect, since a PNG can't specify anisoLevel etc anyway, this may reject any every 8x8 image, unless .name alone is useful.
You are correct: http://dummyimage.com/8x8/f00/fff.png is falsely identified as the "?" by this test. And Bilinear,1,Repeat,0 are simply the default values for Texture, so they are redundant here.
However, it's entirely possible (even probable) that a particular project can be guaranteed to never intentionally require a WWW download of an 8x8 image. In that case, this function is sufficient.