1
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user