38 lines
1009 B
C#
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; // <20><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
public float time; // ˢ<>¼<EFBFBD><C2BC><EFBFBD>
|
|||
|
|
|||
|
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;
|
|||
|
}
|