In my update function I execute a LERP to position my button.
The problem is, once the button has reached its final position, the Lerp function keeps getting executed every update (30 to 60 times per second).
I don’t need the update function anymore when the LERP is finished. How do I achieve this?
You can’t exactly remove the Update function. In your case, all you would need to do is just return once the t value of the Lerp is greater than 0, i.e.
void Update() {
if (Time.time > 1)
return;
transform.localPosition = new Vector3(startpos.x, Mathf.Lerp(startpos.y, maximum, Time.time), startpos.y);
}