/// <summary> /// 计算AB资源的Hash码 /// </summary> public string ComputeHash() { byte[] buffer = ReadAssetBundleBytes(); if (buffer != null) { m_currentHash = TypeConvertUtility.ByteToHash(buffer); } else { m_currentHash = ""; } return(m_currentHash); }
static void SaveLoadingListFile(List <BaseAssetBundleManager> managerList, string path) { StringBuilder sb = new StringBuilder(); string itemPath, name, Hash; int startIndex; byte[] bytes; for (int i = 0, j = 0; i < managerList.Count; i++) { for (j = 0; j < managerList[i].items.Length; j++) { var item = managerList[i].items[j]; if (item.flag == AssetFlag.NoChange) { itemPath = string.Format("{0}/{1}", BuildAssetBundleConfig.buildingAssetBundlesFolder, item.assetBundleName); } else { itemPath = string.Format("{0}/{1}", BuildAssetBundleConfig.differentBuildingAssetBundlesFolder, item.assetBundleName); } startIndex = BuildAssetBundleConfig.buildingAssetBundlesFolder.Length + 1; name = itemPath.Substring(startIndex); bytes = null; bytes = File.ReadAllBytes(itemPath); Hash = TypeConvertUtility.ByteToHash(bytes); sb.AppendFormat("{0},{1},{2};", name, Hash, bytes.Length); } } File.WriteAllText(path, sb.ToString()); }