public static void ClassInitialize(TestContext context)
        {
            var file = @".\Data\bundle_5.3_fs.unity3d";
            var abr  = new AssestFile(file);

            _info = abr.InfoTable;
        }
Ejemplo n.º 2
0
        private void Read(string file)
        {
            Logger.Log("Reading " + file);
            try
            {
                using (BinaryBlock b = new BinaryBlock(File.Open(file, FileMode.Open)))
                {
                    // Use BigEndian for bundle header
                    b.BigEndian = true;

                    // Load the Header info
                    Header = new AssetBundleHeader(b);
                    if (Header.BundleEntries.Count <= 0)
                    {
                        throw new AssetException("No bundle entries found in " + FilePath);
                    }
                    // For art extractor, just grab the first one
                    BundleEntry = Header.BundleEntries.FirstOrDefault();

                    // Move to bundle file offset
                    b.Seek(Header.HeaderSize + BundleEntry.Offset);

                    AssetHeader = new AssetHeader(BundleEntry.Data);
                    Logger.Log(LogLevel.DEBUG, AssetHeader);

                    // TODO: should have a UnityVersion object
                    var version = AssetHeader.AssetVersion;

                    // Should be LittleEndian for assets
                    BundleEntry.Data.BigEndian = AssetHeader.Endianness == 1 ? true : false;
                    Debug.Assert(BundleEntry.Data.BigEndian == false);

                    // For older unity versions specify header size
                    if (version < 9)
                    {
                        BundleEntry.Data.Seek(AssetHeader.FileSize - AssetHeader.MetadataSize + 1);
                    }

                    // Read the bundle metadata, classes and attributes
                    // NOTE: not actually using directly, keeping to keep binary position correct
                    TypeTree = new TypeTree(version);
                    TypeTree.Read(BundleEntry.Data);

                    // Read the asset objects info and offsets
                    InfoTable = new ObjectInfoTable(version);
                    InfoTable.Read(BundleEntry.Data);

                    // NOTE: FileIdentifierTable stuff would go here, but not using it for now

                    // Assign some properties
                    DataOffset = AssetHeader.DataOffset;                    // + Header.DataHeaderSize + Header.HeaderSize;
                    ObjectMap  = InfoTable.InfoMap;
                    // Gather the asset objects plus data together
                    Objects = LoadObjects(BundleEntry.Data);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }