Beispiel #1
0
        public void Read(UnityBinaryReader reader)
        {
            // Read header
            int node_count      = reader.ReadInt();
            int strtable_length = reader.ReadInt();

            // StringTable is at just after nodes
            UnityBinaryReader strtableReader = reader.Slice(reader.Position + 24 * node_count);

            // Read Nodes
            Nodes = new Node[node_count];
            for (int i = 0; i < node_count; i++)
            {
                Nodes[i].Version = reader.ReadUShort();
                Nodes[i].Level   = reader.ReadByte();
                Nodes[i].IsArray = reader.ReadByte() != 0;

                // Read TypeName
                var TypeStringOffset = reader.ReadUShort();
                var temp             = reader.ReadUShort();
                if (temp == 0)
                {
                    strtableReader.Position = TypeStringOffset;
                    Nodes[i].Type           = strtableReader.ReadStringToNull();
                }
                else
                {
                    Nodes[i].Type = GetCommonString(TypeStringOffset);
                }

                // Read Name
                var NameStringOffset = reader.ReadUShort();
                temp = reader.ReadUShort();
                if (temp == 0)
                {
                    strtableReader.Position = NameStringOffset;
                    Nodes[i].Name           = strtableReader.ReadStringToNull();
                }
                else
                {
                    Nodes[i].Name = GetCommonString(NameStringOffset);
                }

                Nodes[i].ByteSize = reader.ReadInt();
                Nodes[i].Index    = reader.ReadInt();
                Nodes[i].MetaFlag = reader.ReadInt();
            }

            reader.Position += strtable_length;
        }
Beispiel #2
0
        public static string ReadAlignedString(this UnityBinaryReader reader)
        {
            string str = reader.ReadString(reader.ReadInt());

            reader.Align(4);
            return(str);
        }
Beispiel #3
0
        // version >= 11
        private void readScripts(UnityBinaryReader reader)
        {
            int script_count = reader.ReadInt();

            Scripts = new ScriptIdentifierType[script_count];
            Scripts.Read(reader);
        }
        private void readExternals(UnityBinaryReader reader)
        {
            int external_count = reader.ReadInt();

            Externals = new ExternalFileType[external_count];
            Externals.Read(reader);
        }
            public void Read(UnityBinaryReader reader)
            {
                var typeEmpty = reader.ReadStringToNull();

                Guid     = new Guid(reader.ReadBytes(16));
                Type     = reader.ReadInt();
                PathName = reader.ReadStringToNull();
            }
        public void Read(UnityBinaryReader reader)
        {
            ClassID         = reader.ReadInt();
            IsStrippedType  = reader.ReadByte() != 0;
            ScriptTypeIndex = reader.ReadShort();

            if (ClassID == (int)ClassIDType.MonoBehaviour)
            {
                ScriptID = reader.ReadBytes(16);
            }
            OldTypeHash = reader.ReadBytes(16);
        }
Beispiel #7
0
        private void readObjects(UnityBinaryReader reader)
        {
            int object_count = reader.ReadInt();

            Objects = new ObjectType[object_count];
            for (int i = 0; i < object_count; i++)
            {
                Objects[i]        = new ObjectType();
                Objects[i].parent = new WeakReference <AssetsFile>(this);

                reader.Align(4);
                Objects[i].PathID = reader.ReadLong();
                var byteStart = reader.ReadUInt();
                var byteSize  = reader.ReadUInt();
                Objects[i].TypeID = reader.ReadInt();

                // Read Body
                var final_pos = reader.Position;
                reader.Position = Header.DataOffset + (int)byteStart;
                Objects[i].Data = reader.ReadBytes((int)byteSize);
                reader.Position = final_pos;
            }
        }
        private void readMetadata(UnityBinaryReader reader)
        {
            // Read Header
            MetadataHeader.Read(reader);

            // Read Types
            int type_count = reader.ReadInt();

            Types = new SerializedType[type_count];
            for (int i = 0; i < type_count; i++)
            {
                Types[i].Read(reader);
                if (MetadataHeader.EnableTypeTree)
                {
                    Types[i].TypeTree = new TypeTree();
                    Types[i].TypeTree.Read(reader);
                }
            }
        }
            public bool   EnableTypeTree; // version >= 13

            public void Read(UnityBinaryReader reader)
            {
                UnityVersion   = reader.ReadStringToNull();
                TargetPlatform = reader.ReadInt();
                EnableTypeTree = reader.ReadByte() != 0;
            }
Beispiel #10
0
 public void Read(UnityBinaryReader reader)
 {
     Index = reader.ReadInt();
     reader.Align(4);
     Identifier = reader.ReadLong();
 }