39 lines
950 B
C#
39 lines
950 B
C#
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using XCharts.Runtime;
|
||
|
|
||
|
[RequireComponent(typeof(BaseChart))]
|
||
|
public class ChartTool : MonoBehaviour
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// UI刷新数据
|
||
|
/// </summary>
|
||
|
public List<Chart> SerieUrl = new List<Chart>();
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
ChartDataUpdateController.Inst.ChartUpdateAction += DataUpdate; // 注册刷新事件
|
||
|
DataUpdate();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 数据刷新函数
|
||
|
/// </summary>
|
||
|
public void DataUpdate()
|
||
|
{
|
||
|
foreach (Chart chart in SerieUrl)
|
||
|
{
|
||
|
WebRequsetTool.Inst.Get(Application.streamingAssetsPath + chart.url, (string data) =>
|
||
|
{
|
||
|
ChartDataUpdateController.Inst.ChartUpdate(chart.type, transform.GetComponent<BaseChart>(), chart, data);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
ChartDataUpdateController.Inst.ChartUpdateAction -= DataUpdate;
|
||
|
}
|
||
|
|
||
|
}
|