- Home /
Texture2D.ReadPixels ignores Sprite Mask, captures hidden sprites
Hey guys,
So I'm curious about Texture2D.ReadPixels function. My company recently updated to Unity 2018.1 and we have been using Texture2D.ReadPixels to take screenshots and set the sprites.
We also use a custom shader to mask out things on the screen.
We started implementing Unity's new Sprite Mask object instead of using our custom shader, and it seems that Texture2D.ReadPixels ignores the hidden symbols in unity's Sprite Mask object. it will capture them regardless if they are hidden or not.
Is this intentional or a bug?
for my understanding, a texture by itself does not know if it's partially hidden or not, it's just a texture. so ReadPixels gives you all pixels, that's it. I think you'd need to 'mask' those pixels yourself in that you get the pixels of the mask too and calculate pixels together.