This commit is contained in:
CortexCore
2025-03-15 20:09:18 +08:00
parent 7979e09be4
commit 824ff2e4c7
106 changed files with 4793 additions and 1618 deletions

View File

@@ -5,6 +5,7 @@ using System.Threading;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Unity.Mathematics;
using UnityEngine;
namespace BITKit.Tween
{
@@ -35,7 +36,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 +63,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