After five seconds the sprite just disappears instantly. I got it from the manual specifically because it said it wouldn’t do that.
The only changes made to the script was that I added the 5 second wait “startFade” (it was still disappearing immediately before I added that) and I had to change “renderer” to “GetComponent()”
using UnityEngine;
using System.Collections;
public class FadeSprite : MonoBehaviour
{
public float fadeWait = 5;
void Start ()
{
StartCoroutine (startFade (fadeWait));
}
IEnumerator Fade()
{
for (float f = 1f; f >= 0; f -= 0.1f)
{
Color c = GetComponent<Renderer>().material.color;
c.a = f;
GetComponent<Renderer>().material.color = c;
yield return null;
}
}
IEnumerator startFade(float wait)
{
yield return new WaitForSeconds(wait);
StartCoroutine ("Fade");
}
}
Sorry I’m not sure if the code tags worked. I read this http://forum.unity3d.com/threads/using-code-tags-properly.143875/ and tried doing what it said but I’m not sure.