public void Read(ByteArray bs) { signature = bs.ReadStringNull(); streamVersion = bs.ReadInt(); unityVersion = bs.ReadStringNull(); unityRevision = bs.ReadStringNull(); minimumStreamedBytes = bs.ReadInt(); headerSize = bs.ReadUInt(); numberOfLevelsToDownload = bs.ReadInt(); int numberOfLevels = bs.ReadInt(); for (int i = 0; i < numberOfLevels; i++) { levelByteEnd.Add(new LevelInfo() { PackSize = bs.ReadUInt(), UncompressedSize = bs.ReadUInt() }); } if (streamVersion >= 2) { completeFileSize = bs.ReadUInt(); } if (streamVersion >= 3) { dataHeaderSize = bs.ReadUInt(); } bs.ReadByte(); }
public void Read(ByteArray inData) { name = inData.ReadStringNull(); offset = inData.ReadUInt(); size = inData.ReadUInt(); Debug.Log(string.Format("name={0},offset={1},size={2}",name,offset,size)); //36+4+4=44 }
public void Read(ByteArray inData) { offset = inData.ReadUInt(); length = inData.ReadUInt(); typeID = inData.ReadInt(); classID = inData.ReadShort(); isDestroyed = inData.ReadShort(); Debug.Log(string.Format("offset={0},length={1},typeID={2},classID={3},isDestroyed={4}", offset, length, typeID, classID, isDestroyed)); }
public void Read(ByteArray inData) { metadataSize = inData.ReadInt(); fileSize = inData.ReadUInt(); assetVersion = inData.ReadInt(); dataOffset = inData.ReadUInt(); if (assetVersion >= 9) { endianness = inData.ReadByte(); inData.ReadBytes(reserved, 0, 3); } Debug.Log(string.Format("metadataSize={0},fileSize={1},versionInfo={2},dataOffset={3}", metadataSize, fileSize, assetVersion, dataOffset)); //4*5=20 }
public void Read(ByteArray inData, AssetHeader assetHeader) { uint entries = inData.ReadUInt(); Debug.Log("FileIdentifierTable:" + entries); for (int i = 0; i < entries; i++) { FileIdentifier fileRef = new FileIdentifier(); fileRef.Read(inData, assetHeader); fileIDs.Add(fileRef); } }
public void Read(ByteArray inData) { uint entries = inData.ReadUInt(); //移动端没有该数据 Debug.Log("ObjectInfoTable:"+entries); for (int i = 0; i < entries; i++) { int pathId = inData.ReadInt(); Debug.Log("pathID:" + pathId); ObjectInfo info = new ObjectInfo(); info.Read(inData); infoMap.Add(pathId, info); } }
public void Read(ByteArray inData) { uint entries = inData.ReadUInt(); //移动端没有该数据 Debug.Log("ObjectInfoTable:" + entries); for (int i = 0; i < entries; i++) { int pathId = inData.ReadInt(); Debug.Log("pathID:" + pathId); ObjectInfo info = new ObjectInfo(); info.Read(inData); infoMap.Add(pathId, info); } }
public AssetBundleReader(string file) { FileStream fs = new FileStream(file, FileMode.Open); BufferedStream bfs = new BufferedStream(fs); byte[] bf = new byte[(int)fs.Length]; fs.Read(bf, 0, (int)fs.Length); inData = new ByteArray(bf); header.Read(inData); if (!header.HasValidSignature()) { Debug.LogError("Invalid signature"); return; } if (header.IsCompressed()) { SevenZip.Compression.LZMA.Decoder coder = new SevenZip.Compression.LZMA.Decoder(); uint length = (uint)(fs.Length - header.GetHeaderSize()); byte[] inBytes = new byte[length]; inData.ReadBytes(inBytes, 0, length); MemoryStream input = new MemoryStream(inBytes); MemoryStream output = new MemoryStream(); // Read the decoder properties byte[] properties = new byte[5]; input.Read(properties, 0, 5); // Read in the decompress file size. byte[] fileLengthBytes = new byte[8]; input.Read(fileLengthBytes, 0, 8); long fileLength = BitConverter.ToInt64(fileLengthBytes, 0); coder.SetDecoderProperties(properties); coder.Code(input, output, input.Length, fileLength, null); output.Position = 0; inData = new ByteArray(output); Debug.Log("fileLength:" + fileLength); } uint files = inData.ReadUInt(); Debug.Log(files); for (int i = 0; i < files; i++) { AssetBundleEntryInfo entryInfo = new AssetBundleEntryInfo(); entryInfo.Read(inData); entryInfos.Add(entryInfo); Debug.Log("AssetBundleEntryInfo"); inData.Postion = (int)entryInfo.GetOffset(); AssetHeader assetHeader = new AssetHeader(); assetHeader.Read(inData); Debug.Log("AssetHeader"); MetadataInfo metadataInfo = new MetadataInfo(); metadataInfo.Read(inData, assetHeader); Debug.Log("MetadataInfo"); //后面的都是小端读取 inData.IsBigEndian = false; ObjectInfoTable objectInfoTable = new ObjectInfoTable(); objectInfoTable.Read(inData); Debug.Log("ObjectInfoTable"); FileIdentifierTable fileIdentifierTable = new FileIdentifierTable(); fileIdentifierTable.Read(inData, assetHeader); Debug.Log("FileIdentifierTable"); } Debug.Log(inData.Postion); }