EnviromentController.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Newtonsoft.Json;
  5. using System.IO;
  6. public class EnviromentController : MonoBehaviour
  7. {
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. // 读取language.json
  12. string filePath = EnviromentSetting.filePath;
  13. string json = File.ReadAllText(filePath);
  14. //json = Regex.Replace(json, @"[\r\n]", "");
  15. EnviromentSetting.languageData = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
  16. // 读取系统语言
  17. string systemLanguage = Application.systemLanguage.ToString();
  18. if (systemLanguage == "ChineseSimplified")
  19. {
  20. EnviromentSetting.languageCode = "zh-cn";
  21. }
  22. // 默认语言为en
  23. // 读取操作系统,unique Id
  24. EnviromentSetting.platform = Application.platform.ToString();
  25. EnviromentSetting.uniqueId = SystemInfo.deviceUniqueIdentifier;
  26. }
  27. // Update is called once per frame
  28. //void Update()
  29. //{
  30. //}
  31. }