EnviromentSetting.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEditorInternal;
  6. using System.Text.RegularExpressions;
  7. using Newtonsoft.Json;
  8. public static class EnviromentSetting
  9. {
  10. // 服务器ip
  11. public const string serverIp = "101.34.23.118";
  12. //language.json读取
  13. public static string filePath = "Assets/Resources/Data/languages.json";
  14. public static Dictionary<string, object> languageData = new();
  15. // access Token
  16. public static string accessToken;
  17. //系统语言 default=en
  18. public static string languageCode = "en";
  19. //操作系统
  20. public static string platform = "NA";
  21. // Unity Unique Id
  22. public static string uniqueId = string.Empty;
  23. //用于获取多层级Dictionary中的value
  24. public static string GetValueAtPath(Dictionary<string, object> root, string[] path)
  25. {
  26. Dictionary<string, object> current = root;
  27. int count = 0;
  28. foreach (string key in path)
  29. {
  30. string rawValue = current[key].ToString();
  31. rawValue = Regex.Replace(rawValue, @"[\r\n]", "");
  32. if (count == path.Length-1)
  33. {
  34. return rawValue;
  35. }
  36. Dictionary<string, object> value = JsonConvert.DeserializeObject<Dictionary<string, object>>(rawValue);
  37. current = value;
  38. count++;
  39. }
  40. return null;
  41. }
  42. }