From 26e4dc3a35d9c778684388de1af8b3f288fe627d Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 28 May 2021 20:00:48 +0800 Subject: *Tween --- .../Scripts/Animation/Tween/TweenModule.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs') diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs index bf2c82b..e42236b 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs @@ -5,11 +5,14 @@ using UnityEngine; namespace TweenAnimation { - public abstract class TweenModule : ScriptableObject + [Serializable] + public abstract class TweenModule { public bool enabled = true; - public float timeOffset; + public float timeOffset = 0; + + public float duration; #if UNITY_EDITOR public new virtual string name { get { return ""; } } @@ -22,9 +25,17 @@ namespace TweenAnimation public bool unfold; #endif - // 根据当前时间更新值 - public virtual void OnUpdate(float time) + // 根据当前时间更新值, time的范围是tween animation的duration + public void OnUpdate(float time) { + float time0 = time - timeOffset; + if (time0 < 0 || time0 > duration) + return; + SetValue(time0); } + + // time是去掉了offset后的时间 + protected abstract void SetValue(float time); + } } \ No newline at end of file -- cgit v1.1-26-g67d0