Exemplo n.º 1
0
        public void Write(UnityBinaryWriter writer)
        {
            // Skip header since strtable_length is unknown
            int header_position = writer.Position;

            writer.Position += 8;

            StringTableBuilder strtable = new StringTableBuilder();

            // Write Nodes
            for (int i = 0; i < Nodes.Length; i++)
            {
                writer.WriteUShort(Nodes[i].Version);
                writer.WriteByte(Nodes[i].Level);
                writer.WriteByte((byte)(Nodes[i].IsArray ? 1 : 0));

                // Write TypeName
                int TypeNameOffset = GetCommonStringID(Nodes[i].Type);
                if (TypeNameOffset == -1)  // Not a common string
                {
                    writer.WriteUShort(strtable.AddString(Nodes[i].Type));
                    writer.WriteUShort(0);
                }
                else
                {
                    writer.WriteUShort((ushort)TypeNameOffset);
                    writer.WriteUShort(0x8000);
                }

                // Write Name
                int NameOffset = GetCommonStringID(Nodes[i].Name);
                if (NameOffset == -1)   // Not a common string
                {
                    writer.WriteUShort(strtable.AddString(Nodes[i].Name));
                    writer.WriteUShort(0);
                }
                else
                {
                    writer.WriteUShort((ushort)NameOffset);
                    writer.WriteUShort(0x8000);
                }

                writer.WriteInt(Nodes[i].ByteSize);
                writer.WriteInt(Nodes[i].Index);
                writer.WriteInt(Nodes[i].MetaFlag);
            }

            // Write StringTable
            byte[] strtable_bytes = strtable.ToBytes();
            writer.WriteBytes(strtable_bytes);

            // Write node_count and strtable_length
            int final_pos = writer.Position;

            writer.Position = header_position;
            writer.WriteInt(Nodes.Length);
            writer.WriteInt(strtable_bytes.Length);
            writer.Position = final_pos;
        }
 public void Write(UnityBinaryWriter writer)
 {
     writer.WriteStringToNull("");
     writer.WriteBytes(Guid.ToByteArray());
     writer.WriteInt(Type);
     writer.WriteStringToNull(PathName);
 }
Exemplo n.º 3
0
        private byte[] writeObjects(UnityBinaryWriter writer)
        {
            writer.WriteInt(Objects.Length);
            UnityBinaryWriter objectwriter = new UnityBinaryWriter();

            for (int i = 0; i < Objects.Length; i++)
            {
                // objects alignment is 8byte
                writer.Align(4);
                writer.WriteLong(Objects[i].PathID);
                objectwriter.Align(8);
                writer.WriteInt(objectwriter.Position);
                writer.WriteInt(Objects[i].Data.Length);
                writer.WriteInt(Objects[i].TypeID);

                objectwriter.WriteBytes(Objects[i].Data);
            }

            // return body
            return(objectwriter.ToBytes());
        }
Exemplo n.º 4
0
        public void Write(UnityBinaryWriter writer)
        {
            writer.WriteInt(ClassID);
            writer.WriteByte((byte)(IsStrippedType ? 1 : 0));
            writer.WriteShort(ScriptTypeIndex);

            if (ClassID == (int)ClassIDType.MonoBehaviour)
            {
                writer.WriteBytes(ScriptID, 0, 16);
            }
            writer.WriteBytes(OldTypeHash, 0, 16);
        }
Exemplo n.º 5
0
        private void writeMetadata(UnityBinaryWriter writer)
        {
            // Write Header
            MetadataHeader.Write(writer);

            // Write Types
            writer.WriteInt(Types.Length);
            for (int i = 0; i < Types.Length; i++)
            {
                Types[i].Write(writer);
                if (MetadataHeader.EnableTypeTree)
                {
                    Types[i].TypeTree.Write(writer);
                }
            }
        }
Exemplo n.º 6
0
 public void Write(UnityBinaryWriter writer)
 {
     writer.WriteStringToNull(UnityVersion);
     writer.WriteInt(TargetPlatform);
     writer.WriteByte((byte)(EnableTypeTree ? 1 : 0));
 }
Exemplo n.º 7
0
 private void writeScripts(UnityBinaryWriter writer)
 {
     writer.WriteInt(Scripts.Length);
     Scripts.Write(writer);
 }
Exemplo n.º 8
0
 public void Write(UnityBinaryWriter writer)
 {
     writer.WriteInt(Index);
     writer.Align(4);
     writer.WriteLong(Identifier);
 }
 private void writeExternals(UnityBinaryWriter writer)
 {
     writer.WriteInt(Externals.Length);
     Externals.Write(writer);
 }