1
This commit is contained in:
@@ -35,7 +35,25 @@ namespace BITKit.Tween
|
||||
return new TweenSequence();
|
||||
}
|
||||
|
||||
public static async UniTask Lerp<T>(Action<T> setter,T from,T to,float duration, Func<T, T,float, T> lerp,CancellationToken cancellationToken = default)
|
||||
public static async UniTask MoveToForward<T>(Action<T> setter, T from, T to, float delta,
|
||||
Func<T, T, float, T> func, CancellationToken cancellationToken = default)
|
||||
{
|
||||
setter(from);
|
||||
while (Equals(from,to) is false && cancellationToken.IsCancellationRequested is false)
|
||||
{
|
||||
from = func(from, to, delta*BITApp.Time.DeltaTime);
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
await UniTask.NextFrame(cancellationToken);
|
||||
#else
|
||||
|
||||
await UniTask.Yield();
|
||||
#endif
|
||||
setter(from);
|
||||
}
|
||||
if (cancellationToken.IsCancellationRequested is false)
|
||||
setter(to);
|
||||
}
|
||||
public static async UniTask Lerp<T>(Action<T> setter,T from,T to,float duration, Func<T, T,float, T> func,CancellationToken cancellationToken = default)
|
||||
{
|
||||
var t = 0f;
|
||||
var delta = 1f / duration;
|
||||
@@ -44,7 +62,7 @@ namespace BITKit.Tween
|
||||
while (t < 1 && cancellationToken.IsCancellationRequested is false)
|
||||
{
|
||||
t = math.clamp(t + delta*BITApp.Time.DeltaTime, 0, 1);
|
||||
var next = lerp(from, to, t);
|
||||
var next = func(from, to, t);
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
await UniTask.NextFrame(cancellationToken);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user