public static AssetsBundleFile CreateBlankBundle(string engineVersion, int contentSize) { AssetsBundleHeader06 header = new AssetsBundleHeader06() { signature = "UnityFS", fileVersion = 6, minPlayerVersion = "5.x.x", fileEngineVersion = engineVersion, totalFileSize = (ulong)(0x82 + engineVersion.Length + contentSize), compressedSize = 0x5B, decompressedSize = 0x5B, flags = 0x40 }; AssetsBundleBlockInfo06 blockInf = new AssetsBundleBlockInfo06 { decompressedSize = (uint)contentSize, compressedSize = (uint)contentSize, flags = 0x0040 }; AssetsBundleDirectoryInfo06 dirInf = new AssetsBundleDirectoryInfo06 { offset = 0, decompressedSize = (uint)contentSize, flags = 4, name = GenerateCabName() }; AssetsBundleBlockAndDirectoryList06 info = new AssetsBundleBlockAndDirectoryList06() { checksumLow = 0, checksumHigh = 0, blockCount = 1, blockInf = new AssetsBundleBlockInfo06[] { blockInf }, directoryCount = 1, dirInf = new AssetsBundleDirectoryInfo06[] { dirInf } }; AssetsBundleFile bundle = new AssetsBundleFile() { bundleHeader6 = header, bundleInf6 = info }; return(bundle); }
private static byte[] GetBundleData(string bunPath, int index) { AssetsFileReader r = new AssetsFileReader(File.Open(bunPath, FileMode.Open, FileAccess.Read, FileShare.Read)); AssetsBundleFile bun = new AssetsBundleFile(); bun.Read(r, true); //if the bundle doesn't have this section return empty if (index >= bun.bundleInf6.dirInf.Length) { return(new byte[0]); } AssetsBundleDirectoryInfo06 dirInf = bun.bundleInf6.dirInf[index]; int start = (int)(bun.bundleHeader6.GetFileDataOffset() + dirInf.offset); int length = (int)dirInf.decompressedSize; byte[] data; r.BaseStream.Position = start; data = r.ReadBytes(length); return(data); }
public static AssetsBundleFile CreateBlankBundle(string engineVersion, int contentSize, int contentSizeSA, string sceneName) { uint infSize = (uint)(0x7B + sceneName.Length * 2); AssetsBundleHeader06 header = new AssetsBundleHeader06() { signature = "UnityFS", fileVersion = 6, minPlayerVersion = "5.x.x", fileEngineVersion = engineVersion, totalFileSize = (ulong)(0x82 + engineVersion.Length + contentSize + contentSizeSA), compressedSize = infSize, //0x5B, decompressedSize = infSize, //0x5B, flags = 0x40 }; AssetsBundleBlockInfo06 blockInfSharedAssets = new AssetsBundleBlockInfo06 { decompressedSize = (uint)contentSizeSA, compressedSize = (uint)contentSizeSA, flags = 0x0040 }; AssetsBundleDirectoryInfo06 dirInfSharedAssets = new AssetsBundleDirectoryInfo06 { offset = 0, decompressedSize = (uint)contentSizeSA, flags = 4, name = "BuildPlayer-" + sceneName + ".sharedAssets" }; AssetsBundleBlockInfo06 blockInf = new AssetsBundleBlockInfo06 { decompressedSize = (uint)contentSize, compressedSize = (uint)contentSize, flags = 0x0040 }; AssetsBundleDirectoryInfo06 dirInf = new AssetsBundleDirectoryInfo06 { offset = (ulong)contentSizeSA, decompressedSize = (uint)contentSize, flags = 4, name = "BuildPlayer-" + sceneName }; AssetsBundleBlockAndDirectoryList06 info = new AssetsBundleBlockAndDirectoryList06() { checksumLow = 0, checksumHigh = 0, blockCount = 2, blockInf = new AssetsBundleBlockInfo06[] { blockInfSharedAssets, blockInf }, directoryCount = 2, dirInf = new AssetsBundleDirectoryInfo06[] { dirInfSharedAssets, dirInf } }; AssetsBundleFile bundle = new AssetsBundleFile() { bundleHeader6 = header, bundleInf6 = info }; return(bundle); }