12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System.Collections;
- using System.IO;
- using Newtonsoft.Json;
- using UnityEngine;
- using UnityEngine.Networking;
- /// <summary>
- /// 指定用户关闭Immersal自动定位
- /// 洋浦党建
- /// </summary>
- public class CloseAutoImmersal : MonoBehaviour
- {
- [SerializeField] private GameObject LocalizeBtn;
- void Start()
- {
- StartCoroutine(ReadFromStreamingAssets());
- }
- IEnumerator ReadFromStreamingAssets()
- {
- var uri = new System.Uri(Path.Combine(Application.streamingAssetsPath, "BlueUserConfig.txt"));
- UnityWebRequest request = UnityWebRequest.Get(uri);
- yield return request.SendWebRequest();
- if (request.result== UnityWebRequest.Result.Success)
- {
- byte[] data = request.downloadHandler.data;
- string jsonString = System.Text.Encoding.UTF8.GetString(data);
- Debug.Log("File content: " + jsonString);
- BlueUserConfig BlueUserConfig = JsonConvert.DeserializeObject<BlueUserConfig>(jsonString);
- if (BlueUserConfig.Auto)
- LocalizeBtn.SetActive(false);
- Debug.Log("BlueUserConfig:"+BlueUserConfig.Auto);
- Debug.Log("LocalizeBtn:"+(LocalizeBtn==null));
- AutoERNIEBot.Auto = BlueUserConfig.Auto;
- AutoERNIEBot.ERNIEBot = BlueUserConfig.ERNIEBot;
- }
- }
- }
- public static class AutoERNIEBot
- {
- public static bool Auto = false;
- public static bool ERNIEBot = false;
- }
|