I’m trying to make a sprite fade in and out. My code simply changes the alpha of the sprite colour in a cycle, going from 0 -1 and down again, repeat.
My code works perfectly in the Unity editor, but when I build for Windows 8 and deploy to my tablet the sprite just stays as 100% opacity.
What is wrong here? My code is below, and as I mentioned it works correctly in the editor.
Is this functionality not available in Windows Store apps? Or is there a better/more robust way of achieving an effect like this?
public class FadeInOut : MonoBehaviour {
public SpriteRenderer spriteObject;
float fade = 0.0f;
float fadeDirection = 0.01f;
// Update is called once per frame
void Update () {
spriteObject.color = new Color( 1f,1f,1f,fade);
fade += fadeDirection;
if (fade >=1.0f)
{
fadeDirection = -0.01f;
}
else if (fade <=0.1)
{
fadeDirection = 0.01f;
}
}
}