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;
        }