ConfigHelper.cs 492 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using UnityEngine;
  3. namespace ET
  4. {
  5. public static class ConfigHelper
  6. {
  7. public static string GetText(string key)
  8. {
  9. try
  10. {
  11. string configStr = ((TextAsset)Game.Scene.GetComponent<ResourcesComponent>().GetAsset("config.unity3d", key)).text;
  12. return configStr;
  13. }
  14. catch (Exception e)
  15. {
  16. throw new Exception($"load config file fail, key: {key}", e);
  17. }
  18. }
  19. public static T ToObject<T>(string str)
  20. {
  21. return JsonHelper.FromJson<T>(str);
  22. }
  23. }
  24. }