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?
You'll get an endless loop where alpha always stays at a fixed value between 1 and 0, unless
What you probably want to use is a coroutine and modify your Mathf.Lerp to Mathf.MoveTowards instead.
Then you can call your coroutine like so:
answered Mar 07 '11 at 02:08 AM