#if ENABLE_GAME_FRAME_X_DO_TWEEN using System; using DG.Tweening; using UnityEngine; namespace GameFrameX.Runtime { /// /// Do Tween 帮助类 /// [UnityEngine.Scripting.Preserve] public static class DoTweenHelper { /// /// 关闭对象上的全部动画 /// /// 物体对象 /// 是否直接完成动画 public static void Kill(GameObject gameObject, bool complete = false) { DOTween.Kill(gameObject, complete); } /// /// 从浮点值到另一个值 /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(float startValue, float endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// 从整形值到另一个值 /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(int startValue, int endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// 从无符号整形值到另一个值 /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(uint startValue, uint endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// 从长整形值到另一个值 /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(long startValue, long endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// 从无符号长整形值到另一个值 /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(ulong startValue, ulong endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// 完成回调 /// public static Tweener To(float startValue, float endValue, float time, Action update, Action complete) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time).OnComplete(() => { complete?.Invoke(); }); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(Vector3 startValue, Vector3 endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// 完成回调 /// public static Tweener To(Vector3 startValue, Vector3 endValue, float time, Action update, Action complete) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time).OnComplete(() => { complete?.Invoke(); }); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(Vector3Int startValue, Vector3Int endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(new Vector3Int((int)m.x, (int)m.y, (int)m.z)); }, endValue, time); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(Vector2 startValue, Vector2 endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// 完成回调 /// public static Tweener To(Vector2 startValue, Vector2 endValue, float time, Action update, Action complete) { return DOTween.To(() => startValue, (m) => { update?.Invoke(m); }, endValue, time).OnComplete(() => { complete?.Invoke(); }); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// public static Tweener To(Vector2Int startValue, Vector2Int endValue, float time, Action update) { return DOTween.To(() => startValue, (m) => { update?.Invoke(new Vector2Int((int)m.x, (int)m.y)); }, endValue, time); } /// /// /// /// 开始值 /// 结束值 /// 持续时长 /// 更新回调 /// 完成回调 /// public static Tweener To(Vector2Int startValue, Vector2Int endValue, float time, Action update, Action complete) { return DOTween.To(() => startValue, (m) => { update?.Invoke(new Vector2Int((int)m.x, (int)m.y)); }, endValue, time).OnComplete(() => { complete?.Invoke(); }); } } } #endif