- Home /
Red 8x8 Question mark texture global replacement
Hello! There are numerous questions covering this, none with a great answer that I've seen.
I'm building an app heavily reliant on live images from the web, and a caching plugin called unicache. We have had some corrupt files from the backend, and very rare errors with the caching plugin that result in an 8x8 texture being displayed which is a red question mark.
Many of the community answers rely on fixing the underlying problem. We're at a place where that seems to have been solved, but is there a solid way to globally just replace that question mark texture with something more professional?
Answer by Bunny83 · May 21, 2019 at 02:00 AM
I'm not quite sure what you're asking. However if you just need a way to detect a corrupted / non existant image, check out this question
So when you look at that question, it is aware of the red question mark I'm talking about. In that example, the solution was downloading the red question mark, then replacing it if it gets assigned to a texture. Is there a cleaner way to solve this, which would be actually replace that red question mark so that in any case, it never would appear?
No, there's no other way as Unity doesn't communicate any kind of failure to you besides returning that question mark texture. So when loading an image you just have to check if the returned image is that question mark texture and if it's the case return the texture you want. They could have returned a null value ins$$anonymous$$d. However that would require anyone loading images dynamically to handle failure cases. So they simply return that question mark texture ins$$anonymous$$d to avoid any errors. If you want to handle the failure cases the amount of work you have to do is pretty much the same except that you first need to have the reference to the failure texture in order to deter$$anonymous$$e if it was successful or not.
yikes! would be ideal to have a failure event and replace with our own, it feels like an odd solution to have to compare the bytes