using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using UnityEngine;
using ZenFulcrum.EmbeddedBrowser;
public class UrlManager : MonoBehaviour
{
public string Url= "";
public Browser ShowBrowser;
private void Awake()
{
//XmlDocument xmlDocument = new XmlDocument();
////配置Url
//string urlconfig = Application.dataPath + "/StreamingAssets/UrlConfig.xml";
//xmlDocument.Load(urlconfig);
//Url = xmlDocument.GetElementsByTagName("Url")[0].InnerText.Trim();
Url = Readjson("url");
if (ShowBrowser)
ShowBrowser.Url = Url;
//browser.EvalJS("document.getElementById('username').value").Then(username => {
// Debug.Log("The username is: " + username);
//}).Done();
}
///
/// 读取JSON文件
///
/// JSON文件中的key值
/// JSON文件中的value值
public static string Readjson(string key)
{
string jsonfile = Application.dataPath + "/StreamingAssets/url.json";//JSON文件路径
using (System.IO.StreamReader file = System.IO.File.OpenText(jsonfile))
{
using (JsonTextReader reader = new JsonTextReader(file))
{
JObject o = (JObject)JToken.ReadFrom(reader);
var value = o[key].ToString();
return value;
}
}
}
// Update is called once per frame
void Update()
{
}
}