diff options
Diffstat (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs')
-rw-r--r-- | Assets/UI_Extension/Scripts/Animation/Tween/TweenController.cs | 51 |
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);
}
}
|