public override void Save(Stream stream, AssetTarget[] targets, AssetBundleManifest manifest, Dictionary <string, HashSet <AssetTarget> > abAssets) { BinaryWriter sw = new BinaryWriter(stream); //写入文件头判断文件类型用,ABDB 意思即 Asset-Bundle-Data-Binary sw.Write(new char[] { 'A', 'B', 'D', 'B' }); List <string> bundleNames = new List <string>(manifest.GetAllAssetBundles()); //写入文件名池 sw.Write(bundleNames.Count); for (int i = 0; i < bundleNames.Count; i++) { sw.Write(bundleNames[i]); } foreach (var bundleName in bundleNames) { //bundle debug name sw.Write(abAssets[bundleName].First().abDebugName); //bundle name sw.Write(bundleNames.IndexOf(bundleName)); //hash sw.Write(manifest.GetAssetBundleHash(bundleName).ToString()); var resCount = abAssets[bundleName].Count; sw.Write(resCount); foreach (var target in abAssets[bundleName]) { sw.Write(AssetBundleUtils.PathConvert(target.assetPath)); } //type // sw.Write((int)target.compositeType); //写入依赖信息 var allDependencies = manifest.GetAllDependencies(bundleName); sw.Write(allDependencies.Length); foreach (var dependency in allDependencies) { sw.Write(bundleNames.IndexOf(dependency)); } } sw.Close(); }
public virtual void Save(Stream stream, AssetTarget[] targets, AssetBundleManifest manifest, Dictionary <string, HashSet <AssetTarget> > abAssets) { StreamWriter sw = new StreamWriter(stream); //写入文件头判断文件类型用,ABDT 意思即 Asset-Bundle-Data-Text sw.WriteLine("ABDT"); var allAssetBundles = manifest.GetAllAssetBundles(); foreach (var bundleName in allAssetBundles) { sw.WriteLine(abAssets[bundleName].First().abDebugName); //bundle name sw.WriteLine(bundleName); //hash sw.WriteLine(manifest.GetAssetBundleHash(bundleName)); var allDependencies = manifest.GetAllDependencies(bundleName); int resCount = abAssets[bundleName].Count; sw.WriteLine(resCount); //AB包中资源数量 foreach (var target in abAssets[bundleName]) { sw.WriteLine(AssetBundleUtils.PathConvert(target.assetPath)); } //type // sw.WriteLine((int)target.compositeType); //写入依赖信息 sw.WriteLine(allDependencies.Length); foreach (var dep in allDependencies) { sw.WriteLine(dep); } sw.WriteLine("<------------->"); } sw.Close(); }