summaryrefslogtreecommitdiff
path: root/Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-05-31 09:43:09 +0800
committerchai <chaifix@163.com>2021-05-31 09:43:09 +0800
commit2683c04adcaff44f9504248d2c983cd86bd4b3ad (patch)
tree1ab3e0ac80b3ace9a8cb1a1f897dbb73d2612d52 /Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs
parent293def05f43c55fce6e90d6b1907c9d9fc63facc (diff)
*tween
Diffstat (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs')
-rw-r--r--Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs51
1 files changed, 38 insertions, 13 deletions
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs
index 561eff6..e2c4495 100644
--- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs
+++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs
@@ -7,29 +7,54 @@ using UnityEngine.Events;
namespace TweenAnimation
{
- [Serializable]
- public class TweenState
- {
- public string name;
- public TweenAnimation animation;
- }
-
public class TweenController : MonoBehaviour
{
- public List<TweenState> animations;
+ public bool autoPlayOnEnable;
+ public string defaultAnimation;
+ public List<TweenAnimation> animations;
- void Start () {
-
- }
+ private string m_Current;
+ private TweenAnimation m_CurrentAnimation;
- public void PlayAnimation(string name)
+ private float m_StartTime;
+
+ public void OnEnable()
{
+ if(autoPlayOnEnable)
+ {
+ PlayAnimation(defaultAnimation);
+ }
+ }
+ public void PlayAnimation(string name)
+ {
+ m_Current = name;
+ m_CurrentAnimation = null;
+ for (int i = 0; i < animations.Count; ++i)
+ {
+ if(animations[i].name == name)
+ {
+ m_CurrentAnimation = animations[i];
+ break;
+ }
+ }
+ if(m_CurrentAnimation == null)
+ {
+ Debug.LogError("No such animation'" + name + "'");
+ }
+ else
+ {
+ m_CurrentAnimation.BeforePlay();
+ }
+ m_StartTime = Time.time;
}
private void Update()
{
-
+ if (m_CurrentAnimation == null)
+ return;
+ float t = Time.time;
+ m_CurrentAnimation.Process(t - m_StartTime);
}
}