- Home /
Is it possible to invert a 2d sprite's colors in Unity?
Like, black becomes white, white becomes black? I know I can apply a color to the material of the Sprite, but that seems to shade everything equally.
Or, am I going to have to make two versions of every image I want to invert and switch between them?
Answer by fafase · May 07, 2015 at 03:33 PM
Use GetPixels on your texture to get all the colors. Then iterate through the array of colors and invert the colors
col = (col == 1) ? 0 : 1;
Then use SetPixels with your array and Apply.
But you would be faster with two textures.
Your answer
Follow this Question
Related Questions
Animator - Stoping && Playing from Specific frames. 5 Answers
Changing "Sprite Mode" from Single to Multiple breaks reference to sprite sheet. 1 Answer
Sprite Renderer Missing Material after running 1 Answer
[JavaScript] Making an image sprite change upon button click? 1 Answer
What can I do to further optimize mobile game? (2D) 0 Answers