chart.AnimationFadeIn();
如果多个图表需要刷新动画可以试试下面的方法参考
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XCharts.Runtime;
/// <summary>
/// XCharts 无数据更新时刷新动画
/// </summary>
/// <typeparam name="T"></typeparam>
public class MyBaseChart<T> : MonoBehaviour where T : BaseChart
{
// 每次间隔多少秒刷新动画
private float second = 5;
//当前实例
private T Tchart;
// 用于控制协程是否继续执行的标志,初始设为true表示可以执行
private bool canContinueCoroutine = true;
// 提供一个外部可调用的方法来开启协程
public void StartActiveChart()
{
if (Tchart == null)
{
Tchart = GetComponent<T>();
}
StartCoroutine(ActiveChart());
canContinueCoroutine = true;
}
// 提供一个外部可调用的方法来停止协程的继续执行
public void StopActiveChart()
{
canContinueCoroutine = false;
}
// 提供一个外部可调用的方法来设置秒数
public void SetSecond(float second)
{
this.second = second;
}
IEnumerator ActiveChart()
{
yield return new WaitForSeconds(second);
Tchart.AnimationFadeIn();
// 判断协程是否还能继续执行,如果为true则继续启动协程,否则就结束
if (canContinueCoroutine)
{
StartCoroutine(ActiveChart());
}
}
}
示例调用
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XCharts.Runtime;
public class CenterBarChart : MyBaseChart<BarChart>
{
public BarChart chart;
// Start is called before the first frame update
void Start()
{
StartActiveChart();
}
}
只是新手不喜勿喷,有更好的方法可以告诉我谢谢大家