I'd like this function to lerp from 0 to 1 and then exit, as opposed to running for a single frame then exiting. As you can see, I've tried wrapping Mathf.Lerp in a while() loop. However, this consistently crashes Unity. How else could I go about achieving this same effect?
static function fadeIn(fadeSpeed : float)
{
// Fades from black to opaque
Debug.Log("Made it here");
alpha = 1;
while(alpha > 0)
{
alpha = Mathf.Lerp(1, 0, fadeSpeed * Time.deltaTime);
Debug.Log("In the while function");
}
}