TestDataReader.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using XRTool.UI;
  7. using XRTool.Util;
  8. using UnityEngine.UI;
  9. public class TestDataReader : MonoBehaviour
  10. {
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. if (DataConfMgr<ServerConfig>.Instance.TableHelper == null)
  15. {
  16. DataConfMgr<ServerConfig>.Instance.OpenData(Application.streamingAssetsPath);
  17. }
  18. if (!DataConfMgr<ServerConfig>.Instance.TableHelper.isInit)
  19. {
  20. DataConfMgr<ServerConfig>.Instance.TableHelper.readConfComplete += OnReadConfComplete;
  21. DataConfMgr<ServerConfig>.Instance.OpenTable("serverName");
  22. }
  23. else
  24. {
  25. OnReadConfComplete();
  26. }
  27. }
  28. private void OnReadConfComplete()
  29. {
  30. var list = DataConfMgr<ServerConfig>.Instance.TableHelper.DataList;
  31. if (list != null)
  32. {
  33. string msg = "";
  34. for (int i = 0; i < list.Count; i++)
  35. {
  36. msg += (JsonConvert.SerializeObject(list[i])) + "\n\n";
  37. }
  38. GetComponent<Text>().text = msg;
  39. }
  40. }
  41. }