CloseAutoImmersal.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections;
  2. using System.IO;
  3. using Newtonsoft.Json;
  4. using UnityEngine;
  5. using UnityEngine.Networking;
  6. /// <summary>
  7. /// 指定用户关闭Immersal自动定位
  8. /// 洋浦党建
  9. /// </summary>
  10. public class CloseAutoImmersal : MonoBehaviour
  11. {
  12. [SerializeField] private GameObject LocalizeBtn;
  13. void Start()
  14. {
  15. StartCoroutine(ReadFromStreamingAssets());
  16. }
  17. IEnumerator ReadFromStreamingAssets()
  18. {
  19. var uri = new System.Uri(Path.Combine(Application.streamingAssetsPath, "BlueUserConfig.txt"));
  20. UnityWebRequest request = UnityWebRequest.Get(uri);
  21. yield return request.SendWebRequest();
  22. if (request.result== UnityWebRequest.Result.Success)
  23. {
  24. byte[] data = request.downloadHandler.data;
  25. string jsonString = System.Text.Encoding.UTF8.GetString(data);
  26. Debug.Log("File content: " + jsonString);
  27. BlueUserConfig BlueUserConfig = JsonConvert.DeserializeObject<BlueUserConfig>(jsonString);
  28. if (BlueUserConfig.Auto)
  29. LocalizeBtn.SetActive(false);
  30. Debug.Log("BlueUserConfig:"+BlueUserConfig.Auto);
  31. Debug.Log("LocalizeBtn:"+(LocalizeBtn==null));
  32. AutoERNIEBot.Auto = BlueUserConfig.Auto;
  33. AutoERNIEBot.ERNIEBot = BlueUserConfig.ERNIEBot;
  34. }
  35. }
  36. }
  37. public static class AutoERNIEBot
  38. {
  39. public static bool Auto = false;
  40. public static bool ERNIEBot = false;
  41. }