33 lines
762 B
C#
33 lines
762 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
|
|
public class TableUpdateTool : MonoBehaviour
|
|
{
|
|
public string Url;
|
|
public Transform parent;
|
|
public GameObject prefab;
|
|
|
|
void Start()
|
|
{
|
|
TableUpdateController.Inst.DataAction += DataUpdate; // 注册刷新事件
|
|
DataUpdate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据刷新函数
|
|
/// </summary>
|
|
void DataUpdate()
|
|
{
|
|
for (int i = 0; i < parent.childCount; i++) {
|
|
Destroy(parent.GetChild(i).gameObject);
|
|
}
|
|
WebRequsetTool.Inst.Get(Application.streamingAssetsPath + Url, (string data) =>
|
|
{
|
|
TableUpdateController.Inst.DataUpdate(parent, prefab, data);
|
|
});
|
|
}
|
|
|
|
}
|