I want to change the alpha value (transparency) of a color back and forth:
private void Awake()
{
material = gameObject.GetComponent<Renderer>().material;
oColor = material.color; // the alpha here is 0
nColor = material.color;
nColor.a = 255f;
}
private void Update()
{
material.color = Color.Lerp(oColor, nColor, Mathf.PingPong(Time.time, 1));
}
This doesn't work, the color instantly changes to white, and it keeps blinking the original color. I'm following this.