This commit is contained in:
CortexCore
2025-03-24 14:42:40 +08:00
parent 18239a5ae4
commit 9845d20f7f
99 changed files with 5418 additions and 5512 deletions

View File

@@ -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