static void PrintFile(TabWriter writer, BuildLayout.File file, int i) { AttrBuilder attr = new AttrBuilder(); if (file.PreloadInfoSize > 0) { attr.AddSize("PreloadInfoSize", (ulong)file.PreloadInfoSize); } attr.Add("MonoScripts", file.MonoScriptCount.ToString()); attr.AddSize("MonoScript Size", file.MonoScriptSize); using (writer.IndentScope($"File {i} {attr}")) { foreach (BuildLayout.SubFile sf in file.SubFiles) { AttrBuilder attr2 = new AttrBuilder(); attr2.AddSize("Size", sf.Size); writer.WriteLine($"{sf.Name} {attr2}"); } using (writer.IndentScope($"Data From Other Assets ({file.OtherAssets.Count})")) { foreach (BuildLayout.DataFromOtherAsset otherData in file.OtherAssets) { PrintDataFromOtherAsset(writer, otherData); } } } }
static void PrintDataFromOtherAsset(TabWriter writer, BuildLayout.DataFromOtherAsset asset) { AttrBuilder attr = new AttrBuilder(); attr.AddSize("Size", asset.SerializedSize + asset.StreamedSize); attr.AddSize("Size from Objects", asset.SerializedSize); attr.AddSize("Size from Streamed Data", asset.StreamedSize); attr.Add("Object Count", asset.ObjectCount.ToString()); using (writer.IndentScope($"{asset.AssetPath} {attr}")) { writer.WriteLine($"Referencing Assets: {string.Join(", ", asset.ReferencingAssets.Select(x => x.AssetPath))}"); } }
static void PrintArchive(TabWriter writer, BuildLayout.Bundle archive) { AttrBuilder attr = new AttrBuilder(); attr.AddSize("Size", archive.FileSize); attr.Add("Compression", archive.Compression); ulong bundleSize = archive.Files.First(x => x.BundleObjectInfo != null).BundleObjectInfo.Size; attr.AddSize("Asset Bundle Object Size", bundleSize); using (writer.IndentScope($"Archive {archive.Name} {attr}")) { if (archive.Dependencies != null) { writer.WriteLine("Bundle Dependencies: " + string.Join(", ", archive.Dependencies.Select(x => x.Name))); } if (archive.ExpandedDependencies != null) { writer.WriteLine("Expanded Bundle Dependencies: " + string.Join(", ", archive.ExpandedDependencies.Select(x => x.Name))); } using (writer.IndentScope($"Explicit Assets")) { for (int i = 0; i < archive.Files.Count; i++) { BuildLayout.File f = archive.Files[i]; foreach (BuildLayout.ExplicitAsset asset in f.Assets) { PrintAsset(writer, asset, i); } } } using (writer.IndentScope($"Files:")) { for (int i = 0; i < archive.Files.Count; i++) { PrintFile(writer, archive.Files[i], i); } } } }
static void PrintAsset(TabWriter writer, BuildLayout.ExplicitAsset asset, int fileIndex) { AttrBuilder attr = new AttrBuilder(); attr.AddSize("Total Size", asset.SerializedSize + asset.StreamedSize); attr.AddSize("Size from Objects", asset.SerializedSize); attr.AddSize("Size from Streamed Data", asset.StreamedSize); attr.Add("File Index", fileIndex.ToString()); attr.Add("Addressable Name", asset.AddressableName); using (writer.IndentScope($"{asset.AssetPath} {attr}")) { if (asset.ExternallyReferencedAssets.Count > 0) { writer.WriteLine("External References: " + string.Join(", ", asset.ExternallyReferencedAssets.Select(x => x.AssetPath))); } if (asset.InternalReferencedOtherAssets.Count > 0) { writer.WriteLine("Internal References: " + string.Join(", ", asset.InternalReferencedOtherAssets.Select(x => x.AssetPath))); } } }
static void PrintGroup(TabWriter writer, BuildLayout.Group grp) { int explicitAssetCount = grp.Bundles.Sum(x => x.Files.Sum(y => y.Assets.Count)); AttrBuilder attr = new AttrBuilder(); attr.Add("Bundles", grp.Bundles.Count.ToString()); attr.AddSize("Total Size", (ulong)grp.Bundles.Sum(x => (long)x.FileSize)); attr.Add("Explicit Asset Count", explicitAssetCount.ToString()); using (writer.IndentScope($"Group {grp.Name} {attr}")) { using (writer.IndentScope("Schemas")) grp.Schemas.ForEach(x => PrintSchema(writer, x)); foreach (BuildLayout.Bundle archive in grp.Bundles) { PrintArchive(writer, archive); } } }