mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 13:28:47 +00:00
增加Animation的customFadeInDelay等自定义数据项延时和时长回调函数
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.06.07) 增加`Animation`的`customFadeInDelay`等自定义数据项延时和时长回调函数
|
||||||
* (2020.06.07) 优化`PieChart`在数据全为`0`时的显示为等份的效果
|
* (2020.06.07) 优化`PieChart`在数据全为`0`时的显示为等份的效果
|
||||||
* (2020.06.04) 增加`SerieLabel`的`autoOffset`参数设置是否自动判断上下偏移
|
* (2020.06.04) 增加`SerieLabel`的`autoOffset`参数设置是否自动判断上下偏移
|
||||||
* (2020.06.04) 增加`Tooltip`的`alwayShow`参数设置触发后一直显示
|
* (2020.06.04) 增加`Tooltip`的`alwayShow`参数设置触发后一直显示
|
||||||
|
|||||||
@@ -686,9 +686,10 @@
|
|||||||
|
|
||||||
* `enable`:是否开启动画系统。
|
* `enable`:是否开启动画系统。
|
||||||
* ~~`threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。~~
|
* ~~`threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。~~
|
||||||
* `fadeInDelay`:设定的渐入动画延时,单位毫秒。
|
* `fadeInDelay`:设定的渐入动画延时,单位毫秒。如果要设置单个数据项的延时,可以用代码定制:`customFadeInDelay`。
|
||||||
* `fadeInDuration`:设定的渐入动画时长,单位毫秒。
|
* `fadeInDuration`:设定的渐入动画时长,单位毫秒。如果要设置单个数据项的渐入时长,可以用代码定制:`customFadeInDuration`。
|
||||||
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。
|
* `fadeOutDelay`:设定的渐出动画延时,单位毫秒。如果要设置单个数据项的延时,可以用代码定制:`customFadeOutDelay`。
|
||||||
|
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。如果要设置单个数据项的渐出时长,可以用代码定制:`customFadeOutDuration`。
|
||||||
* `dataChangeEnable`:是否开启数据变更动画。
|
* `dataChangeEnable`:是否开启数据变更动画。
|
||||||
* `dataChangeDuration`:数据变更动画时长,单位毫秒。
|
* `dataChangeDuration`:数据变更动画时长,单位毫秒。
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_FadeInDelay = prop.FindPropertyRelative("m_FadeInDelay");
|
SerializedProperty m_FadeInDelay = prop.FindPropertyRelative("m_FadeInDelay");
|
||||||
SerializedProperty m_Threshold = prop.FindPropertyRelative("m_Threshold");
|
SerializedProperty m_Threshold = prop.FindPropertyRelative("m_Threshold");
|
||||||
SerializedProperty m_ActualDuration = prop.FindPropertyRelative("m_ActualDuration");
|
SerializedProperty m_ActualDuration = prop.FindPropertyRelative("m_ActualDuration");
|
||||||
|
SerializedProperty m_FadeOutDelay = prop.FindPropertyRelative("m_FadeOutDelay");
|
||||||
// SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
|
// SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
|
||||||
// SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
|
// SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
|
||||||
|
|
||||||
@@ -40,15 +41,18 @@ namespace XCharts
|
|||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
//EditorGUI.PropertyField(drawRect, m_Easting);
|
//EditorGUI.PropertyField(drawRect, m_Easting);
|
||||||
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Threshold);
|
// EditorGUI.PropertyField(drawRect, m_Threshold);
|
||||||
if (m_Threshold.intValue < 0) m_Threshold.intValue = 0;
|
// if (m_Threshold.intValue < 0) m_Threshold.intValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FadeInDelay);
|
EditorGUI.PropertyField(drawRect, m_FadeInDelay);
|
||||||
if (m_FadeInDelay.floatValue < 0) m_FadeInDelay.floatValue = 0;
|
if (m_FadeInDelay.floatValue < 0) m_FadeInDelay.floatValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FadeInDuration);
|
EditorGUI.PropertyField(drawRect, m_FadeInDuration);
|
||||||
if (m_FadeInDuration.floatValue < 0) m_FadeInDuration.floatValue = 0;
|
if (m_FadeInDuration.floatValue < 0) m_FadeInDuration.floatValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_FadeOutDelay);
|
||||||
|
if (m_FadeOutDelay.floatValue < 0) m_FadeOutDelay.floatValue = 0;
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FadeOutDuration);
|
EditorGUI.PropertyField(drawRect, m_FadeOutDuration);
|
||||||
if (m_FadeOutDuration.floatValue < 0) m_FadeOutDuration.floatValue = 0;
|
if (m_FadeOutDuration.floatValue < 0) m_FadeOutDuration.floatValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|||||||
43
Assets/XCharts/Examples/Runtime/Example03_ChartAnimation.cs
Normal file
43
Assets/XCharts/Examples/Runtime/Example03_ChartAnimation.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts.Examples
|
||||||
|
{
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class Example03_ChartAnimation : MonoBehaviour
|
||||||
|
{
|
||||||
|
BaseChart chart;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
chart = gameObject.GetComponent<BaseChart>();
|
||||||
|
if (chart == null)
|
||||||
|
{
|
||||||
|
chart = gameObject.AddComponent<BarChart>();
|
||||||
|
}
|
||||||
|
var serie = chart.series.GetSerie(0);
|
||||||
|
serie.animation.enable = true;
|
||||||
|
//自定义每个数据项的渐入延时
|
||||||
|
serie.animation.customFadeInDelay = CustomFadeInDelay;
|
||||||
|
//自定义每个数据项的渐入时长
|
||||||
|
serie.animation.customFadeInDuration = CustomFadeInDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CustomFadeInDelay(int dataIndex)
|
||||||
|
{
|
||||||
|
return dataIndex * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CustomFadeInDuration(int dataIndex)
|
||||||
|
{
|
||||||
|
return dataIndex * 1000 + 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6258ca3b055714eac92804f501011b53
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Threading;
|
/******************************************/
|
||||||
/******************************************/
|
|
||||||
/* */
|
/* */
|
||||||
/* Copyright (c) 2018 monitor1394 */
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
/* https://github.com/monitor1394 */
|
/* https://github.com/monitor1394 */
|
||||||
@@ -8,9 +7,13 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
|
public delegate float CustomAnimationDelay(int dataIndex);
|
||||||
|
public delegate float CustomAnimationDuration(int dataIndex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the animation of serie.
|
/// the animation of serie.
|
||||||
/// 动画表现。
|
/// 动画表现。
|
||||||
@@ -28,9 +31,26 @@ namespace XCharts
|
|||||||
[SerializeField] private float m_FadeInDuration = 1000;
|
[SerializeField] private float m_FadeInDuration = 1000;
|
||||||
[SerializeField] private float m_FadeInDelay = 0;
|
[SerializeField] private float m_FadeInDelay = 0;
|
||||||
[SerializeField] private float m_FadeOutDuration = 1000f;
|
[SerializeField] private float m_FadeOutDuration = 1000f;
|
||||||
|
[SerializeField] private float m_FadeOutDelay = 0;
|
||||||
[SerializeField] private bool m_DataChangeEnable = true;
|
[SerializeField] private bool m_DataChangeEnable = true;
|
||||||
[SerializeField] private float m_DataChangeDuration = 500;
|
[SerializeField] private float m_DataChangeDuration = 500;
|
||||||
[SerializeField] private float m_ActualDuration;
|
[SerializeField] private float m_ActualDuration;
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义渐入动画延时函数。返回ms值。
|
||||||
|
/// </summary>
|
||||||
|
public CustomAnimationDelay customFadeInDelay;
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义渐入动画时长函数。返回ms值。
|
||||||
|
/// </summary>
|
||||||
|
public CustomAnimationDuration customFadeInDuration;
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义渐出动画延时函数。返回ms值。
|
||||||
|
/// </summary>
|
||||||
|
public CustomAnimationDelay customFadeOutDelay;
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义渐出动画时长函数。返回ms值。
|
||||||
|
/// </summary>
|
||||||
|
public CustomAnimationDuration customFadeOutDuration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to enable animation.
|
/// Whether to enable animation.
|
||||||
@@ -44,12 +64,12 @@ namespace XCharts
|
|||||||
//public Easing easing { get { return m_Easting; } set { m_Easting = value; } }
|
//public Easing easing { get { return m_Easting; } set { m_Easting = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The milliseconds duration of the fadeIn animation.
|
/// The milliseconds duration of the fadeIn animation.
|
||||||
/// 设定的渐入动画时长(毫秒)。
|
/// 设定的渐入动画时长(毫秒)。如果要设置单个数据项的渐入时长,可以用代码定制:customFadeInDuration。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float fadeInDuration { get { return m_FadeInDuration; } set { m_FadeInDuration = value < 0 ? 0 : value; } }
|
public float fadeInDuration { get { return m_FadeInDuration; } set { m_FadeInDuration = value < 0 ? 0 : value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The milliseconds duration of the fadeOut animation.
|
/// The milliseconds duration of the fadeOut animation.
|
||||||
/// 设定的渐出动画时长(毫秒)。
|
/// 设定的渐出动画时长(毫秒)。如果要设置单个数据项的渐出时长,可以用代码定制:customFadeOutDuration。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float fadeOutDuration { get { return m_FadeOutDuration; } set { m_FadeOutDuration = value < 0 ? 0 : value; } }
|
public float fadeOutDuration { get { return m_FadeOutDuration; } set { m_FadeOutDuration = value < 0 ? 0 : value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -64,9 +84,13 @@ namespace XCharts
|
|||||||
public int threshold { get { return m_Threshold; } set { m_Threshold = value; } }
|
public int threshold { get { return m_Threshold; } set { m_Threshold = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The milliseconds delay before updating the first animation.
|
/// The milliseconds delay before updating the first animation.
|
||||||
/// 动画延时(毫秒)。
|
/// 渐入动画延时(毫秒)。如果要设置单个数据项的延时,可以用代码定制:customFadeInDelay。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float delay { get { return m_FadeInDelay; } set { m_FadeInDelay = value < 0 ? 0 : value; } }
|
public float fadeInDelay { get { return m_FadeInDelay; } set { m_FadeInDelay = value < 0 ? 0 : value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 渐出动画延时(毫秒)。如果要设置单个数据项的延时,可以用代码定制:customFadeOutDelay。
|
||||||
|
/// </summary>
|
||||||
|
public float fadeOutDelay { get { return m_FadeOutDelay; } set { m_FadeInDelay = value < 0 ? 0 : value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否开启数据变更动画。
|
/// 是否开启数据变更动画。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -77,7 +101,8 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
|
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
|
||||||
|
|
||||||
private Dictionary<int, float> m_DataAnimationState = new Dictionary<int, float>();
|
private Dictionary<int, float> m_DataCurrProgress = new Dictionary<int, float>();
|
||||||
|
private Dictionary<int, float> m_DataDestProgress = new Dictionary<int, float>();
|
||||||
private bool m_FadeIn = false;
|
private bool m_FadeIn = false;
|
||||||
private bool m_IsEnd = true;
|
private bool m_IsEnd = true;
|
||||||
private bool m_IsPause = false;
|
private bool m_IsPause = false;
|
||||||
@@ -112,7 +137,8 @@ namespace XCharts
|
|||||||
m_CurrDetailProgress = 0;
|
m_CurrDetailProgress = 0;
|
||||||
m_DestDetailProgress = 1;
|
m_DestDetailProgress = 1;
|
||||||
m_CurrSymbolProgress = 0;
|
m_CurrSymbolProgress = 0;
|
||||||
m_DataAnimationState.Clear();
|
m_DataCurrProgress.Clear();
|
||||||
|
m_DataDestProgress.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
@@ -139,7 +165,8 @@ namespace XCharts
|
|||||||
m_CurrDetailProgress = 0;
|
m_CurrDetailProgress = 0;
|
||||||
m_DestDetailProgress = 1;
|
m_DestDetailProgress = 1;
|
||||||
m_CurrSymbolProgress = 0;
|
m_CurrSymbolProgress = 0;
|
||||||
m_DataAnimationState.Clear();
|
m_DataCurrProgress.Clear();
|
||||||
|
m_DataDestProgress.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pause()
|
public void Pause()
|
||||||
@@ -161,7 +188,7 @@ namespace XCharts
|
|||||||
private void End()
|
private void End()
|
||||||
{
|
{
|
||||||
if (m_IsEnd) return;
|
if (m_IsEnd) return;
|
||||||
m_ActualDuration = (int)((Time.time - startTime) * 1000) - delay;
|
m_ActualDuration = (int)((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
|
||||||
m_CurrDataProgress = m_DestDataProgress + (m_FadeOut ? -1 : 1);
|
m_CurrDataProgress = m_DestDataProgress + (m_FadeOut ? -1 : 1);
|
||||||
m_FadeIn = false;
|
m_FadeIn = false;
|
||||||
m_IsEnd = true;
|
m_IsEnd = true;
|
||||||
@@ -181,7 +208,7 @@ namespace XCharts
|
|||||||
m_IsPause = false;
|
m_IsPause = false;
|
||||||
m_FadeOut = false;
|
m_FadeOut = false;
|
||||||
m_FadeOuted = false;
|
m_FadeOuted = false;
|
||||||
m_DataAnimationState.Clear();
|
m_DataCurrProgress.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitProgress(int data, float curr, float dest)
|
public void InitProgress(int data, float curr, float dest)
|
||||||
@@ -209,32 +236,73 @@ namespace XCharts
|
|||||||
m_CurrDataProgress = dataIndex + (m_FadeOut ? -1 : 1);
|
m_CurrDataProgress = dataIndex + (m_FadeOut ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDataState(int index, float state)
|
private void SetDataCurrProgress(int index, float state)
|
||||||
{
|
{
|
||||||
m_DataAnimationState[index] = state;
|
m_DataCurrProgress[index] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetDataState(int index, float dest)
|
private float GetDataCurrProgress(int index, float initValue, float destValue)
|
||||||
{
|
{
|
||||||
if (IsInDelay()) return dest;
|
if (IsInDelay()) return initValue;
|
||||||
if (!m_DataAnimationState.ContainsKey(index))
|
if (!m_DataCurrProgress.ContainsKey(index))
|
||||||
{
|
{
|
||||||
m_DataAnimationState.Add(index, dest);
|
m_DataCurrProgress.Add(index, initValue);
|
||||||
|
m_DataDestProgress.Add(index, destValue);
|
||||||
}
|
}
|
||||||
return m_DataAnimationState[index];
|
return m_DataCurrProgress[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFinish()
|
public bool IsFinish(int dataCount = -1)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying) return true;
|
if (!Application.isPlaying) return true;
|
||||||
#endif
|
#endif
|
||||||
|
if (dataCount > 0 && (!IsAllOutDelay(dataCount) || !IsAllDataFinishProgress(dataCount))) return false;
|
||||||
return !m_Enable || m_IsEnd || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
|
return !m_Enable || m_IsEnd || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInDelay()
|
public bool IsInDelay()
|
||||||
{
|
{
|
||||||
return (delay > 0 && Time.time - startTime < delay / 1000);
|
if (m_FadeOut) return (fadeOutDelay > 0 && Time.time - startTime < fadeOutDelay / 1000);
|
||||||
|
return (fadeInDelay > 0 && Time.time - startTime < fadeInDelay / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetDataDelay(int dataIndex)
|
||||||
|
{
|
||||||
|
if (m_FadeOut && customFadeOutDelay != null) return customFadeOutDelay(dataIndex);
|
||||||
|
if (m_FadeIn && customFadeInDelay != null) return customFadeInDelay(dataIndex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsInDataDelay(int dataIndex)
|
||||||
|
{
|
||||||
|
return Time.time - startTime < GetDataDelay(dataIndex) / 1000f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsAllOutDelay(int dataCount)
|
||||||
|
{
|
||||||
|
var nowTime = Time.time - startTime;
|
||||||
|
for (int i = 0; i < dataCount; i++)
|
||||||
|
{
|
||||||
|
if (nowTime < GetDataDelay(i) / 1000) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsAllDataFinishProgress(int dataCount)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < dataCount; i++)
|
||||||
|
{
|
||||||
|
if (m_DataDestProgress.ContainsKey(i) && m_DataCurrProgress.ContainsKey(i))
|
||||||
|
{
|
||||||
|
if (m_DataCurrProgress[i] != m_DataDestProgress[i]) return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckDetailBreak(float detail)
|
public bool CheckDetailBreak(float detail)
|
||||||
@@ -262,7 +330,7 @@ namespace XCharts
|
|||||||
if (IsFinish()) return;
|
if (IsFinish()) return;
|
||||||
if (!m_IsInit || m_IsPause || m_IsEnd) return;
|
if (!m_IsInit || m_IsPause || m_IsEnd) return;
|
||||||
if (IsInDelay()) return;
|
if (IsInDelay()) return;
|
||||||
m_ActualDuration = (int)((Time.time - startTime) * 1000) - delay;
|
m_ActualDuration = (int)((Time.time - startTime) * 1000) - fadeInDelay;
|
||||||
var duration = GetCurrAnimationDuration();
|
var duration = GetCurrAnimationDuration();
|
||||||
var delta = total / duration * Time.deltaTime;
|
var delta = total / duration * Time.deltaTime;
|
||||||
if (m_FadeOut)
|
if (m_FadeOut)
|
||||||
@@ -285,43 +353,54 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal float GetCurrAnimationDuration()
|
internal float GetCurrAnimationDuration(int dataIndex = -1)
|
||||||
{
|
{
|
||||||
if (m_FadeOut) return m_FadeOutDuration > 0 ? m_FadeOutDuration / 1000 : 1;
|
if (dataIndex >= 0)
|
||||||
else return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1;
|
{
|
||||||
|
if (m_FadeOut && customFadeOutDuration != null) return customFadeOutDuration(dataIndex) / 1000f;
|
||||||
|
if (m_FadeIn && customFadeInDuration != null) return customFadeInDuration(dataIndex) / 1000f;
|
||||||
|
}
|
||||||
|
if (m_FadeOut) return m_FadeOutDuration > 0 ? m_FadeOutDuration / 1000 : 1f;
|
||||||
|
else return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal float CheckBarProgress(int dataIndex, float barHig)
|
internal float CheckBarProgress(int dataIndex, float barHig, int dataCount)
|
||||||
{
|
{
|
||||||
//if (!m_IsInit) return barHig;
|
var initHig = m_FadeOut ? barHig : 0;
|
||||||
var destHig = m_FadeOut ? barHig : 0;
|
var destHig = m_FadeOut ? 0 : barHig;
|
||||||
if (IsInDelay() || IsFinish() || m_IsEnd)
|
if (IsFinish() || m_IsEnd)
|
||||||
{
|
{
|
||||||
return m_FadeOuted ? 0 : barHig;
|
return m_FadeOuted ? 0 : barHig;
|
||||||
}
|
}
|
||||||
|
else if (IsInDelay() || IsInDataDelay(dataIndex))
|
||||||
|
{
|
||||||
|
return m_FadeOut ? barHig : 0;
|
||||||
|
}
|
||||||
else if (m_IsPause)
|
else if (m_IsPause)
|
||||||
{
|
{
|
||||||
return GetDataState(dataIndex, destHig);
|
return GetDataCurrProgress(dataIndex, initHig, destHig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var duration = GetCurrAnimationDuration();
|
var duration = GetCurrAnimationDuration(dataIndex);
|
||||||
var delta = barHig / duration * Time.deltaTime;
|
var delta = barHig / duration * Time.deltaTime;
|
||||||
var currHig = GetDataState(dataIndex, destHig) + (m_FadeOut ? -delta : delta);
|
var currHig = GetDataCurrProgress(dataIndex, initHig, destHig) + (m_FadeOut ? -delta : delta);
|
||||||
SetDataState(dataIndex, currHig);
|
|
||||||
if (m_FadeOut)
|
if (m_FadeOut)
|
||||||
{
|
{
|
||||||
if ((destHig > 0 && currHig <= 0) || (destHig < 0 && currHig >= 0))
|
if ((initHig > 0 && currHig <= 0) || (initHig < 0 && currHig >= 0))
|
||||||
{
|
{
|
||||||
End();
|
|
||||||
currHig = 0;
|
currHig = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Mathf.Abs(currHig) >= Mathf.Abs(barHig))
|
else if (Mathf.Abs(currHig) >= Mathf.Abs(barHig))
|
||||||
{
|
{
|
||||||
End();
|
|
||||||
currHig = barHig;
|
currHig = barHig;
|
||||||
}
|
}
|
||||||
|
SetDataCurrProgress(dataIndex, currHig);
|
||||||
|
if (IsAllOutDelay(dataCount) && IsAllDataFinishProgress(dataCount))
|
||||||
|
{
|
||||||
|
End();
|
||||||
|
}
|
||||||
return currHig;
|
return currHig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace XCharts
|
|||||||
|
|
||||||
private float CheckAnimation(Serie serie, int dataIndex, float barHig)
|
private float CheckAnimation(Serie serie, int dataIndex, float barHig)
|
||||||
{
|
{
|
||||||
float currHig = serie.animation.CheckBarProgress(dataIndex, barHig);
|
float currHig = serie.animation.CheckBarProgress(dataIndex, barHig,serie.dataCount);
|
||||||
if (!serie.animation.IsFinish())
|
if (!serie.animation.IsFinish())
|
||||||
{
|
{
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
|
|||||||
Reference in New Issue
Block a user