Hello, I made a black fade out image on my scene to give it a fade out effect using an
Image Screenshot - 01c7373a6c994c1007cd9ac70323be42 - Gyazo
The code i am using is:
public class IntroStorylineController : MonoBehaviour {
public Text IntroText;
public float alphaLevel = 1f;
public float totalTime = 0;
void Start () {
//StartCoroutine (waitTime ());
}
void Update () {
totalTime += Time.deltaTime;
if (totalTime >= .2) {
alphaLevel -= .01f;
totalTime = 0;
}
GetComponent().color = new Color (0, 0, 0, alphaLevel);
}
IEnumerator waitTime() {
yield return new WaitForSeconds (3f);
Update ();
IntroText.enabled = false;
}
}
The scene fades out correctly but am getting a recurring null reference exception
on GetComponent().color = new Color (0, 0, 0, alphaLevel);
I have the above script attached to the image gameobject.
Any1 knows what might be going wrong please? Thanks