Is there any way I could put this method on a different thread?
I've tried putting the functions inside a Thread, but I cannot use the ref keyword in them. I've also tried making the method asynchronous, but those don't support ref either. It works if I call the function like this:
new Thread(() => x.Animate(0f, 1f, 1000, Ease.Linear)).Start();
but this seems inconvenient.
public static void Animate(this ref float value, float start, float change, int duration, Ease easing)
{
Stopwatch timer = new Stopwatch();
timer.Start();
while (timer.ElapsedMilliseconds <= duration)
{
value = easing.Execute((int)timer.ElapsedMilliseconds, start, change, duration);
}
timer.Stop();
}