diff --git a/Runtime/Component/Animation/AnimationInfo.cs b/Runtime/Component/Animation/AnimationInfo.cs
index 2e037433..f7a78b49 100644
--- a/Runtime/Component/Animation/AnimationInfo.cs
+++ b/Runtime/Component/Animation/AnimationInfo.cs
@@ -4,6 +4,10 @@ using UnityEngine;
namespace XCharts.Runtime
{
+ ///
+ /// the animation info.
+ /// |动画配置参数。
+ ///
[Since("v3.8.0")]
[System.Serializable]
public class AnimationInfo
@@ -14,17 +18,53 @@ namespace XCharts.Runtime
[SerializeField][Since("v3.8.0")] private float m_Duration = 1000;
public AnimationInfoContext context = new AnimationInfoContext();
+ ///
+ /// whether enable animation.
+ /// |是否开启动画效果。
+ ///
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
+ ///
+ /// whether enable reverse animation.
+ /// |是否开启反向动画效果。
+ ///
public bool reverse { get { return m_Reverse; } set { m_Reverse = value; } }
+ ///
+ /// the delay time before animation start.
+ /// |动画开始前的延迟时间。
+ ///
public float delay { get { return m_Delay; } set { m_Delay = value; } }
+ ///
+ /// the duration of animation.
+ /// |动画的时长。
+ ///
public float duration { get { return m_Duration; } set { m_Duration = value; } }
+ ///
+ /// the callback function of animation start.
+ /// |动画开始的回调。
+ ///
public Action OnAnimationStart { get; set; }
+ ///
+ /// the callback function of animation end.
+ /// |动画结束的回调。
+ ///
public Action OnAnimationEnd { get; set; }
+ ///
+ /// the delegate function of animation delay.
+ /// |动画延迟的委托函数。
+ ///
public AnimationDelayFunction delayFunction { get; set; }
+ ///
+ /// the delegate function of animation duration.
+ /// |动画时长的委托函数。
+ ///
public AnimationDurationFunction durationFunction { get; set; }
+ ///
+ /// Reset animation.
+ /// |重置动画。
+ ///
public void Reset()
{
if (!enable) return;
@@ -36,6 +76,11 @@ namespace XCharts.Runtime
context.itemCurrProgress.Clear();
}
+ ///
+ /// Start animation.
+ /// |开始动画。
+ ///
+ /// 是否重置上一次的参数
public void Start(bool reset = true)
{
if (!enable) return;
@@ -65,6 +110,10 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Pause animation.
+ /// |暂停动画。
+ ///
public void Pause()
{
if (!enable) return;
@@ -72,6 +121,10 @@ namespace XCharts.Runtime
context.pause = true;
}
+ ///
+ /// Resume animation.
+ /// |恢复动画。
+ ///
public void Resume()
{
if (!enable) return;
@@ -79,6 +132,10 @@ namespace XCharts.Runtime
context.pause = false;
}
+ ///
+ /// End animation.
+ /// |结束动画。
+ ///
public void End()
{
if (!enable) return;
@@ -93,6 +150,14 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Initialize animation.
+ /// |初始化动画。
+ ///
+ /// 当前进度
+ /// 目标进度
+ /// 目标索引
+ ///
public bool Init(float curr, float dest, int totalPointIndex)
{
if (!enable || !context.start) return false;
@@ -113,6 +178,10 @@ namespace XCharts.Runtime
return true;
}
+ ///
+ /// Whether animation is finish.
+ /// |动画是否结束。
+ ///
public bool IsFinish()
{
if (!context.start) return true;
@@ -121,6 +190,10 @@ namespace XCharts.Runtime
return context.currProgress == context.destProgress;
}
+ ///
+ /// Whether animation is in delay.
+ /// |动画是否在延迟中。
+ ///
public bool IsInDelay()
{
if (!context.start)
@@ -129,6 +202,12 @@ namespace XCharts.Runtime
return (m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000);
}
+ ///
+ /// Whether animation is in index delay.
+ /// |动画是否在索引延迟中。
+ ///
+ ///
+ ///
public bool IsInIndexDelay(int dataIndex)
{
if (context.start)
@@ -137,6 +216,12 @@ namespace XCharts.Runtime
return false;
}
+ ///
+ /// Get animation delay.
+ /// |获取动画延迟。
+ ///
+ ///
+ ///
public float GetIndexDelay(int dataIndex)
{
if (!context.start) return 0;
@@ -279,24 +364,40 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Fade in animation.
+ /// |淡入动画。
+ ///
[Since("v3.8.0")]
[System.Serializable]
public class AnimationFadeIn : AnimationInfo
{
}
+ ///
+ /// Fade out animation.
+ /// |淡出动画。
+ ///
[Since("v3.8.0")]
[System.Serializable]
- public class AnimationFadeOut : AnimationInfo
+ public class AnimationFadeout : AnimationInfo
{
}
+ ///
+ /// Data change animation.
+ /// |数据变更动画。
+ ///
[Since("v3.8.0")]
[System.Serializable]
public class AnimationChange : AnimationInfo
{
}
+ ///
+ /// Data addition animation.
+ /// |数据新增动画。
+ ///
[Since("v3.8.0")]
[System.Serializable]
public class AnimationAddition : AnimationInfo
diff --git a/Runtime/Component/Animation/AnimationStyle.cs b/Runtime/Component/Animation/AnimationStyle.cs
index 2c058566..5b55bda6 100644
--- a/Runtime/Component/Animation/AnimationStyle.cs
+++ b/Runtime/Component/Animation/AnimationStyle.cs
@@ -56,7 +56,7 @@ namespace XCharts.Runtime
[SerializeField] private int m_Threshold = 2000;
[SerializeField][Since("v3.4.0")] private bool m_UnscaledTime;
[SerializeField][Since("v3.8.0")] private AnimationFadeIn m_Fadein = new AnimationFadeIn();
- [SerializeField][Since("v3.8.0")] private AnimationFadeOut m_Fadeout = new AnimationFadeOut() { reverse = true };
+ [SerializeField][Since("v3.8.0")] private AnimationFadeout m_Fadeout = new AnimationFadeout() { reverse = true };
[SerializeField][Since("v3.8.0")] private AnimationChange m_Change = new AnimationChange() { duration = 500 };
[SerializeField][Since("v3.8.0")] private AnimationAddition m_Addition = new AnimationAddition() { duration = 500 };
@@ -103,7 +103,7 @@ namespace XCharts.Runtime
/// Fade out animation configuration.
/// |渐出动画配置。
///
- public AnimationFadeOut fadeout { get { return m_Fadeout; } }
+ public AnimationFadeout fadeout { get { return m_Fadeout; } }
///
/// Update data animation configuration.
/// |数据变更动画配置。
@@ -133,6 +133,10 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// The actived animation.
+ /// |当前激活的动画。
+ ///
public AnimationInfo activedAnimation
{
get
@@ -145,12 +149,20 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Start fadein animation.
+ /// |开始渐入动画。
+ ///
public void Fadein()
{
if (m_Fadeout.context.start) return;
m_Fadein.Start();
}
+ ///
+ /// Restart the actived animation.
+ /// |重启当前激活的动画。
+ ///
public void Restart()
{
var anim = activedAnimation;
@@ -161,11 +173,19 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Start fadeout animation.
+ /// |开始渐出动画。
+ ///
public void Fadeout()
{
m_Fadeout.Start();
}
+ ///
+ /// Start additon animation.
+ /// |开始数据新增动画。
+ ///
public void Addition()
{
if (!enable) return;
@@ -175,6 +195,10 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Pause all animations.
+ /// |暂停所有动画。
+ ///
public void Pause()
{
foreach (var anim in animations)
@@ -183,6 +207,10 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Resume all animations.
+ /// |恢复所有动画。
+ ///
public void Resume()
{
foreach (var anim in animations)
@@ -191,12 +219,23 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Reset all animations.
+ ///
public void Reset()
{
- m_Fadein.Reset();
- m_Fadeout.Reset();
+ foreach (var anim in animations)
+ {
+ anim.Reset();
+ }
}
+ ///
+ /// Initialize animation configuration.
+ /// |初始化动画配置。
+ ///
+ /// 当前进度
+ /// 目标进度
public void InitProgress(float curr, float dest)
{
var anim = activedAnimation;
@@ -220,6 +259,12 @@ namespace XCharts.Runtime
}
}
+ ///
+ /// Initialize animation configuration.
+ /// |初始化动画配置。
+ ///
+ /// 路径坐标点列表
+ /// 是Y轴还是X轴
public void InitProgress(List paths, bool isY)
{
if (paths.Count < 1) return;
diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs
index 8ddc3cd8..962ec9d4 100644
--- a/Runtime/Internal/BaseChart.API.cs
+++ b/Runtime/Internal/BaseChart.API.cs
@@ -382,8 +382,8 @@ namespace XCharts.Runtime
}
///
- /// Whether series animation enabel.
- /// |启用或关闭起始动画。
+ /// Whether enable serie animations.
+ /// |是否启用Serie动画。
///
///
public void AnimationEnable(bool flag)
@@ -392,24 +392,24 @@ namespace XCharts.Runtime
}
///
- /// fadeIn animation.
- /// |开始渐入动画。
+ /// Start all serie fadein animations.
+ /// |开始所有Serie的渐入动画。
///
+ /// reset animation
public void AnimationFadein(bool reset = true)
{
- if (reset)
- AnimationReset();
+ if (reset) AnimationReset();
foreach (var serie in m_Series) serie.AnimationFadein();
}
-
+
[Obsolete("Use AnimationFadein() instead.", true)]
public void AnimationFadeIn(bool reset = true)
{
}
///
- /// fadeIn animation.
- /// |开始渐出动画。
+ /// Start all serie fadeout animations.
+ /// |开始所有Serie的渐出动画。
///
public void AnimationFadeout()
{
@@ -422,8 +422,8 @@ namespace XCharts.Runtime
}
///
- /// Pause animation.
- /// |暂停动画。
+ /// Pause all animations.
+ /// |暂停所有Serie的动画。
///
public void AnimationPause()
{
@@ -431,8 +431,8 @@ namespace XCharts.Runtime
}
///
- /// Stop play animation.
- /// |继续动画。
+ /// Resume all animations.
+ /// |继续所有Serie的动画。
///
public void AnimationResume()
{
@@ -440,8 +440,8 @@ namespace XCharts.Runtime
}
///
- /// Reset animation.
- /// |重置动画。
+ /// Reset all animations.
+ /// |重置所有Serie的动画。
///
public void AnimationReset()
{