Change transparency of a sprite

I am creating a 2D game with a lot of sprites. I need fade-in and fade-out effects for these sprites.25068-upload.jpg

So, I tried adding a material with a diffuse shader and changing the alpha value. The problem I am facing is that instead of only the mesh changing the alpha value the entire sprite box is changing color and I am getting a black rectangle. Any suggestions?

float speed = .01f; //the speed that your alpha changes (between 0 and 1, I think)

Color color = renderer.material.color;

color.a -= speed;

renderer.material.color = color;

Are you doing something like this in your script? If that isn’t working, I would assume that your background color on your sprite isn’t truly transparent.

Alternately, you could try using an image editor to create several copies of your sprite at different levels of opacity, add them to a sprite sheet, and use unity to create an animation of the fading effect.