This commit is contained in:
CortexCore
2025-03-09 13:38:23 +08:00
parent 8261a458e2
commit 18239a5ae4
67 changed files with 8573 additions and 831 deletions

View File

@@ -35,26 +35,18 @@ namespace BITKit.Tween
return new TweenSequence();
}
public static async UniTask MoveToForward(
Action<float> setter,
float from,
float to,
float duration = 1,
CancellationToken cancellationToken = default
)
public static async UniTask Lerp<T>(Action<T> setter,T from,T to,float duration, Func<T, T,float, T> lerp,CancellationToken cancellationToken = default)
{
var t = 0f;
var delta = 1 / duration;
var delta = 1f / duration;
setter(from);
//BIT4Log.Log<TweenSequence>($"已创建Tween,from:[{from}]to:[{to}]duration:[{duration}]delta:[{delta}]");
while (t < 1 && cancellationToken.IsCancellationRequested is false)
{
t = math.clamp(t + delta*BITApp.Time.DeltaTime, 0, 1);
var next = math.lerp(from, to, t);
//BIT4Log.Log<TweenSequence>($"当前进度:[{t}]next:[{next}]");
var next = lerp(from, to, t);
#if UNITY_5_3_OR_NEWER
await UniTask.NextFrame(cancellationToken);
await UniTask.SwitchToMainThread(cancellationToken);
#else
await UniTask.Yield();
#endif