// Use this for initialization public void Run(Action end) { this.end = end; netDL = new DllVersionList(); localDL = new Dictionary <string, DllVersion>(); InitGame(); }
IEnumerator DownSetting(string url) { UnityWebRequest www = UnityWebRequest.Get(url); yield return(www.SendWebRequest()); while (www.isDone == false) { if (progress != null) { progress.Invoke(www.downloadProgress, "获取配置"); } } if (string.IsNullOrEmpty(www.error)) { List <DllVersion> needUpdateDll = new List <DllVersion>(); netDL = JsonMapper.ToObject <DllVersionList>(www.downloadHandler.text); for (int i = 0; i < netDL.item.Count; i++) { if (localDL.ContainsKey(netDL.item[i].dllName)) { if (netDL.item[i].version > localDL[netDL.item[i].dllName].version) { needUpdateDll.Add(netDL.item[i]); } } else { needUpdateDll.Add(netDL.item[i]); } } if (needUpdateDll.Count > 0) { StartCoroutine(DownDll(needUpdateDll)); } else { if (end != null) { end(); } } } else { if (updateFail != null) { updateFail.Invoke("配置获取错误"); } Debug.LogError("配置获取错误"); } }
void InitGame() { nowUtc = DateTime.UtcNow.ToFileTimeUtc(); string url = FileTools.GetDllNetPath(jsonName + "?v=" + nowUtc); // string url = FileTools.GetDllNetPath(jsonName); local = FileTools.ReadText <DllVersionList>(localPath + jsonName); if (local == null) { local = new DllVersionList(); DllVersion dv = new DllVersion(); dv.dllName = Main.Instance.runtimeConfig.runTimeName + ".zip"; dv.version = 0; local.item.Add(dv); FileTools.CreateFile(localPath, jsonName, local); } for (int i = 0; i < local.item.Count; i++) { localDL.Add(local.item[i].dllName, local.item[i]); } StartCoroutine(DownSetting(url)); }