using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ByCode : MonoBehaviour { public Root myroot = new Root(); public Dictionary lineCode_dic = new Dictionary(); void Start() { } // Update is called once per frame void Update() { } /// /// 线路类型查询 /// /// /// public IEnumerator getByCode(Action callback) { yield return StartCoroutine( CombineJSON.GetJson_GET(GameManager.Inst.Jk_URL.xllx_cx, GameManager.Inst.arguments.token, (jsonResult) => { if (!string.IsNullOrEmpty(jsonResult)) { try { myroot = JsonConvert.DeserializeObject(jsonResult); if (myroot.data != null && myroot.message == "操作成功") { lineCode_dic.Clear(); for (int i = 0; i < myroot.data.Count; i++) { //if (!lineCode_dic.ContainsKey(myroot.data[i].name)) lineCode_dic.Add(myroot.data[i].name, myroot.data[i].value); } callback.Invoke("1"); } else { Debug.Log("线路类型查询失败:" + myroot.message); callback.Invoke(null); } } catch (Exception e) { Debug.Log("查询线路类型接口错误:" + e.Message + e.StackTrace); callback.Invoke(null); } } else { callback.Invoke(null); } })); } [System.Serializable] public class Data { /// /// /// public string id; /// /// /// public string code; /// /// 名字 /// public string name; /// /// /// public string value; /// /// /// //public int deleteFlag; /// /// /// public string remark; /// /// /// //public int createTime; } [System.Serializable] public class Root { /// /// /// public string code; /// /// 操作成功 /// public string message; /// /// /// public List data; /// /// /// public string serverTime; } }