Example #1
0
        Stream OpenUnityRaw(ArcFile arc, Entry entry)
        {
            using (var stream = arc.File.CreateStream(entry.Offset, entry.Size))
                using (var input = new AssetReader(stream))
                {
                    var signature = input.ReadCString();
                    if (signature != "UnityRaw")
                    {
                        return(base.OpenEntry(arc, entry));
                    }
                    int format = input.ReadInt32();
                    input.ReadCString();
                    input.ReadCString();
                    uint file_size = input.ReadUInt32();
                    if (file_size != entry.Size)
                    {
                        return(base.OpenEntry(arc, entry));
                    }
                    uint header_size  = input.ReadUInt32();
                    int  entry_count  = input.ReadInt32();
                    int  bundle_count = input.ReadInt32();
                    if (entry_count != 1 || bundle_count != 1)
                    {
                        return(base.OpenEntry(arc, entry));
                    }

                    input.Position = header_size;
                    int  count     = input.ReadInt32();
                    long asset_pos = input.Position;
                    input.ReadCString(); // asset_name
                    header_size = input.ReadUInt32();
                    uint asset_size = input.ReadUInt32();
                    long base_pos   = asset_pos + header_size - 4;

                    input.Position = base_pos;
                    var index = new ResourcesAssetsDeserializer(arc.File.Name);
                    var dir   = index.Parse(input, base_pos);
                    if (null == dir || 0 == dir.Count)
                    {
                        return(base.OpenEntry(arc, entry));
                    }
                    ;
                    return(arc.File.CreateStream(entry.Offset + dir[0].Offset, dir[0].Size));
                }
        }