AnnulusGames / LitMotion

Lightning-fast and Zero Allocation Tween Library for Unity.
https://annulusgames.github.io/LitMotion/
MIT License
828 stars 66 forks source link

Add `TryCancel` / `TryComplete` #144

Closed AnnulusGames closed 1 day ago

AnnulusGames commented 1 day ago

TryCancel() and TryComplete() have been added to MotionHandle. This makes it possible to write the following code more concisely.

// before
if (handle.IsActive())
{
    handle.Cancel();
}

// after
handle.TryCancel();

In addition, calling Complete() for infinitely looping motions has been changed to throw InvalidOperationException. Furthermore, the error message has been improved to make it easier for users to understand.