Alpha Channel Problem In Unity
I just thought I would throw this out here because Unity has this unusual quirk and it has driven me (along with some other very talented developer friends of mine) to the brink of cosmic insanity. If you have ever created a texture in Unity that has an alpha channel but the alpha information in Unity is completely incorrect, then it's most likely because you have "empty pixels" in your RGB channels. What are empty pixels? Just think about anytime you've erased all the way through your layers in Photoshop and you can see the white and grey grid underneath. You can see that grid because you've removed color information from those areas and Photoshop just wants you to know that. Unity understands those empty pixels and will create an alpha channel for you if you have them in your image.
A quick and easy way to to test this out:
- Create a new layer at the bottom of the layer stack.
- Fill the whole thing with an arbitrary color.
- Re-save it and check it out in Unity. You should now see an alpha on the texture in Unity that looks like the alpha channel you intentionally created.
This happens because Unity has two different ways of recognizing transparent elements in a texture. One of these ways is through the alpha channel, and the other way is through empty pixels in the RGB channels. When it sees both it simply defers to the empty pixels. So all you have to do is fill those up with something so it knows it needs to look at the actual alpha channel. I hope this saves you some furious self-hair-removal. :)