ConfigHelper.cs 756 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using UnityEngine;
  3. namespace Model
  4. {
  5. public static class ConfigHelper
  6. {
  7. public static string GetText(string key)
  8. {
  9. try
  10. {
  11. GameObject config = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("config", "Config");
  12. string configStr = config.Get<TextAsset>(key).text;
  13. return configStr;
  14. }
  15. catch (Exception e)
  16. {
  17. throw new Exception($"load config file fail, key: {key}", e);
  18. }
  19. }
  20. public static string GetGlobal()
  21. {
  22. try
  23. {
  24. GameObject config = (GameObject)Resources.Load("KV");
  25. string configStr = config.Get<TextAsset>("GlobalProto").text;
  26. return configStr;
  27. }
  28. catch (Exception e)
  29. {
  30. throw new Exception($"load global config file fail", e);
  31. }
  32. }
  33. }
  34. }