private void InitRemoteConfig() { SetJindu("正在检查本地资源版本,请稍候"); AOutput.Log("InitRemoteConfig"); ConfigDownloader.Instance.StartToDownload(ConfigURL, () => { ParseConfigs(); if (UConfigManager.bUsingAb) { SetJindu("正在加载脚本资源......"); StartCoroutine(OnDownloadDll(ConfigDownloader.Instance.OnGetValue("dll"))); } else { SetJindu("正在加载脚本资源..."); LoadDll(File.ReadAllBytes("Assets/RemoteResources/Dll/ahotgames.bytes") , File.ReadAllBytes("Assets/RemoteResources/Dll/ahotgames.pdb")); } }, () => { SetJindu("正在加载本地资源,请稍候"); Debug.Log("下载远端配置文件失败,加载本地文件"); UConfigManager.bUsingAb = false; StartCoroutine(OnDownloadDll(UStaticFuncs.GetStreamAssetPath() + UStaticFuncs.GetPlatformFolder(Application.platform) + "/dll/ahotgames.ab")); }); }
private IEnumerator DoLoadFileList(string fileListName) { lfiles.Clear(); var www = new WWW(UStaticFuncs.GetStreamAssetPath() + UStaticFuncs.GetPlatformFolder(Application.platform) + "/" + fileListName); yield return(www); if (string.IsNullOrEmpty(www.error)) { var atext = www.text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var t in atext) { var fname = ""; var av = t.Split('|'); if (av.Length <= 2) { continue; } fname = av[0]; if (fname.StartsWith("/") || fname.StartsWith("\\")) { fname = fname.Substring(1); } fname = fname.Replace("\\", "/"); if (fname.EndsWith(".meta")) { continue; } lfiles.Add(fname); } totalCount = lfiles.Count; OnCopyFile(); } else { AOutput.Log("DoCopyFile failed:" + www.error + " for file " + www.url); actionOnComp?.Invoke(); } }
private IEnumerator DoCopyFile(string fname) { var www = new WWW(UStaticFuncs.GetStreamAssetPath() + UStaticFuncs.GetPlatformFolder(Application.platform) + "/" + fname); yield return(www); if (string.IsNullOrEmpty(www.error)) { var finfo = new FileInfo(UStaticFuncs.ConfigSaveDir + fname); if (!finfo.Directory.Exists) { finfo.Directory.Create(); } System.IO.File.WriteAllBytes(finfo.FullName, www.bytes); } else { AOutput.Log("DoCopyFile failed:" + www.error + " for file " + www.url); } AOutput.Log("正在释放资源,不消耗流量。"); OnCopyFile(); }