EnviromentSetting.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /* 本文件包含EnviromentSetting 主要功能上游戏运行环境设定
  9. */
  10. public static class EnviromentSetting
  11. {
  12. // 服务器ip
  13. public const string serverIp = "101.34.23.118";
  14. //language.json读取
  15. public static string filePath = "Assets/Resources/Data/languages.json";
  16. public static Dictionary<string, object> languageData = null;
  17. // access Token
  18. public static string accessToken;
  19. //系统语言 default=en
  20. public static string languageCode = "en";
  21. //操作系统
  22. public static string platform = "NA";
  23. // Unity Unique Id
  24. public static string UUID = null;
  25. //用于获取多层级Dictionary中的value
  26. public static string GetValueAtPath(Dictionary<string, object> root, string[] path)
  27. {
  28. Dictionary<string, object> current = root;
  29. int count = 0;
  30. foreach (string key in path)
  31. {
  32. string rawValue = current[key].ToString();
  33. rawValue = Regex.Replace(rawValue, @"[\r\n]", "");
  34. if (count == path.Length-1)
  35. {
  36. return rawValue;
  37. }
  38. Dictionary<string, object> value = JsonConvert.DeserializeObject<Dictionary<string, object>>(rawValue);
  39. current = value;
  40. count++;
  41. }
  42. return null;
  43. }
  44. }