39 lines
968 B
C#
39 lines
968 B
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.Events;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class GetDataController : Singleton<GetDataController>
|
|||
|
{
|
|||
|
public UnityAction DataAction; // <20><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
public float time; // ˢ<>¼<EFBFBD><C2BC><EFBFBD>
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
InvokeRepeating("DataActionUpdate", 0, time);
|
|||
|
}
|
|||
|
|
|||
|
private void DataActionUpdate() {
|
|||
|
DataAction?.Invoke();
|
|||
|
}
|
|||
|
|
|||
|
public void DataUpdate(NumberOpation[] opations,string data)
|
|||
|
{
|
|||
|
List<NumberData> numberData = JsonDataTool.Inst.JsonToOptionList<NumberData>(data);
|
|||
|
for (int i = 0; i < opations.Length; i++) {
|
|||
|
opations[i].text.text = string.Format(opations[i].format, numberData[i].data == null ? "--" : numberData[i].data);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class NumberOpation {
|
|||
|
public Text text;
|
|||
|
public string format;
|
|||
|
}
|
|||
|
|
|||
|
public struct NumberData {
|
|||
|
public float? data;
|
|||
|
}
|