mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-15 12:40:12 +00:00
3.0
This commit is contained in:
37
Examples/Example03_ChartAnimation.cs
Normal file
37
Examples/Example03_ChartAnimation.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[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.GetSerie(0);
|
||||
serie.animation.enable = true;
|
||||
//自定义每个数据项的渐入延时
|
||||
serie.animation.fadeInDelayFunction = CustomFadeInDelay;
|
||||
//自定义每个数据项的渐入时长
|
||||
serie.animation.fadeInDurationFunction = CustomFadeInDuration;
|
||||
}
|
||||
|
||||
float CustomFadeInDelay(int dataIndex)
|
||||
{
|
||||
return dataIndex * 1000;
|
||||
}
|
||||
|
||||
float CustomFadeInDuration(int dataIndex)
|
||||
{
|
||||
return dataIndex * 1000 + 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user