diff options
author | chai <chaifix@163.com> | 2021-05-28 20:00:48 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-05-28 20:00:48 +0800 |
commit | 26e4dc3a35d9c778684388de1af8b3f288fe627d (patch) | |
tree | e791e224c2be0dcda69dda2211d213f946b3b2cc /Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs | |
parent | 3bf862ea76d349c2aec1f71656dd6f41a82650e0 (diff) |
*Tween
Diffstat (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs')
-rw-r--r-- | Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs | 19 |
1 files changed, 15 insertions, 4 deletions
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 |