AnnulusGames / LitMotion

Lightning-fast and Zero Allocation Tween Library for Unity.

Home Page:https://annulusgames.github.io/LitMotion/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Proposal] Make await handle; to throw OperationCanceledException when MotionHandle.Cancel.

Akeit0 opened this issue · comments

It is odd that await handle does not throw an exception when the MotionHandle itself is canceled, even though handle.ToUniTask(cts.Token) throws an exception on CancellationTokenSource cancellation.

public void OnMotionCanceled()
{
    if (cancellationToken.IsCancellationRequested)
    {
        canceled = true;
    }
    if (canceled)
    {
        core.TrySetCanceled(cancellationToken);
    }
    else
    {
        core.TrySetCanceled();
       // core.TrySetResult(AsyncUnit.Default);
    }
}

It is certainly more natural to cancel the await, so I changed the behavior to do so. (#23)