void GenVersionInfoFile(string folderPath, string subFolder) { ClientVersionConfig versionConfig = new ClientVersionConfig(); // 打包完成后 foreach (System.IO.FileInfo fileInfo in FileHelper.GetAllFiles(folderPath, "*.u3d")) { string md5 = MD5Helper.GetFileMD5(fileInfo.FullName); string path = string.IsNullOrEmpty(subFolder) ? fileInfo.Name : $"{subFolder}/{fileInfo.Name}"; versionConfig.FileInfoDict[path] = new FileVersionInfo(fileInfo.Name, md5, fileInfo.Length); } string content = JsonUtility.ToJson(new Serialization <string, FileVersionInfo>(versionConfig.FileInfoDict)); string versionPath = string.IsNullOrEmpty(subFolder) ? folderPath : $"{folderPath}/{subFolder}"; versionPath.CreateFolderIfNotExist(); FileHelper.WriteFile($"{versionPath}/version.json", content); }
private IEnumerator StartRequestResource() { TextAsset text = Resources.Load <TextAsset>("version"); if (null == text) { Logger.LogError("load versoin text failed!!!"); yield break; } else { clientVersionConfig = Pathfinding.Serialization.JsonFx.JsonReader.Deserialize <ClientVersionConfig>(text.text); if (null == clientVersionConfig) { Logger.LogError("deserialize client version text failed!!!"); yield break; } } DeviceInfo.SetGameVersion(clientVersionConfig.GameVersion); string versionFileName = string.Format("version_{0}.json", DeviceInfo.GameVersion); for (int index = 0; index < clientVersionConfig.ResourceUrls.Count; ++index) { ResourceItem item = clientVersionConfig.ResourceUrls[index]; string requestUrl = string.Format("{0}{1}/{2}/{3}", item.Url, GameConstant.PlatformDirectory, DeviceInfo.GameVersion.ToLower(), versionFileName); string platformInfos = string.Empty; AssetBundleManager.Instance.DownloadAssetAsync(requestUrl, null, (abInfo) => { platformInfos = abInfo.text; }); float startTime = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup - startTime < item.Timeout) { if (!string.IsNullOrEmpty(platformInfos)) { try { serverVersionConfig = Pathfinding.Serialization.JsonFx.JsonReader.Deserialize <ServerVersionConfig>(platformInfos); if (null != serverVersionConfig) { GameConstant.SetResourceUrl(item.Url); break; } } catch { Logger.LogError("deserialize server version config failed!!!"); } } yield return(null); } if (null != serverVersionConfig) { break; } } yield return(StartCoroutine(SetPlatformConfig())); }