I have a user interface with a info button, when you press it a text box should animate forward, by animating the scale of it, so it “grows out”. I’ve done this by using coroutines that animates the scaling with Lerp. The problem is that if you press the button twice you get strange behaviors; it’s like the courotines stacks up and plays again and again. I’ve tried using StopCoroutine(“AnimateScale”) and StopAllCoroutines() to abort the first animation but it didn’t work.
So how would you animate your GUI elements with code? Should I just move all the animation code in to the Update() method and control it with Booleans wheater the animation should be playing or not? The problem then is that the code needs to check every frame if it should animate or not, and most of the time it shouldn’t animate (it’s not a button that you should need to press very often), so it sounds like a waste of performance. That’s way I looked into coroutines, for performance, but they don’t seam to give me the control I need. Since I need to be able to abort or reverse the animation at any time.