/// <summary> /// 生成目录下所有AssertBundle信息文件的MD5信息 /// </summary> /// <param name="abPath"></param> public static void BuildBundleMD5Files(string abPath) { string assetBundlePath = abPath;// Path.Combine(abPath, ABPathHelper.platformFolder); if (!Directory.Exists(assetBundlePath)) { return; } //先删除AllGameConfig文件 string config_path = ABPathHelper.GetCombinePath(assetBundlePath, ABPathHelper.localVerMD5File); if (File.Exists(config_path)) { File.Delete(config_path); } Dictionary <string, string> newFileMD5Map = new Dictionary <string, string>(); string[] files = Directory.GetFiles(assetBundlePath, "*", SearchOption.AllDirectories); FileStream fs = new FileStream(assetBundlePath + "/" + ABPathHelper.localVerMD5File, FileMode.OpenOrCreate); using (StreamWriter sw = new StreamWriter(fs)) { string filePath = ""; string fileMd5 = string.Empty; string fileExt = ""; string fileName = ""; long fileSize = 0; foreach (string file in files) { #if UNITY_EDITOR_OSX filePath = file.Replace(assetBundlePath + "/", ""); #else filePath = file.Replace(assetBundlePath + "\\", ""); #endif if (filePath.Contains(ABPathHelper.localVerMD5File)) { continue; } fileExt = Path.GetExtension(filePath); fileName = Path.GetFileNameWithoutExtension(filePath); if (!fileExt.Equals(ABPathHelper.Unity3dSuffix) && !fileExt.Equals(ABPathHelper.MP4Suffix)) { continue; } //判断是否与空格 if (filePath.Contains(" ")) { Debug.Log("<color=red>有问题资源:</color>" + filePath); continue; } CUtility.MD5Hash(file, ref fileMd5, ref fileSize); sw.WriteLine(string.Format("{0}*{1}*{2}", filePath, fileMd5, fileSize)); } } fs.Close(); fs.Dispose(); }