using System.Collections;
using System.IO;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Networking;
///
/// 指定用户关闭Immersal自动定位
/// 洋浦党建
///
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(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;
}