You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
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(); |
|
} |
|
/// <summary> |
|
/// 读取JSON文件 |
|
/// </summary> |
|
/// <param name="key">JSON文件中的key值</param> |
|
/// <returns>JSON文件中的value值</returns> |
|
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() |
|
{ |
|
|
|
} |
|
}
|
|
|