Files
ZHGD_Web/Assets/Script/Controller/TableUpdateController.cs
2025-07-13 23:16:20 +08:00

38 lines
1009 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class TableUpdateController : Singleton<TableUpdateController>
{
public UnityAction DataAction; // Êý¾Ý¸üÐÂʼþ
public float time; // ˢмä¸ô
private void Start()
{
InvokeRepeating("DataActionUpdate", time, time);
}
private void DataActionUpdate()
{
DataAction?.Invoke();
}
public void DataUpdate(Transform parent,GameObject prefab, string data)
{
List<TableData> tableData = JsonDataTool.Inst.JsonToOptionList<TableData>(data);
for (int i = 0; i < tableData.Count; i++)
{
GameObject temp = Instantiate(prefab, parent);
for (int j = 0; j < tableData[i].data.Count; j++)
{
temp.transform.GetChild(j).GetComponent<Text>().text = tableData[i].data[j];
}
}
}
}
public class TableData {
public List<string> data;
}