EnviromentSetting.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 UUID = string.Empty;
  23. //多个宠物的列表
  24. public static List<DogProperty> puppies = new();
  25. // 开发阶段代码,加载宠物
  26. public static void InitialPuppies(DogProperty puppy)
  27. {
  28. puppies.Add(puppy);
  29. }
  30. //用于获取多层级Dictionary中的value
  31. public static string GetValueAtPath(Dictionary<string, object> root, string[] path)
  32. {
  33. Dictionary<string, object> current = root;
  34. int count = 0;
  35. foreach (string key in path)
  36. {
  37. string rawValue = current[key].ToString();
  38. rawValue = Regex.Replace(rawValue, @"[\r\n]", "");
  39. if (count == path.Length-1)
  40. {
  41. return rawValue;
  42. }
  43. Dictionary<string, object> value = JsonConvert.DeserializeObject<Dictionary<string, object>>(rawValue);
  44. current = value;
  45. count++;
  46. }
  47. return null;
  48. }
  49. }