Example #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;
        }
Example #2
0
 public void Write(UnityBinaryWriter writer)
 {
     writer.WriteIntBE(MetadataSize);
     writer.WriteIntBE(FileSize);
     writer.WriteIntBE(Version);
     writer.WriteIntBE(DataOffset);
     writer.WriteByte((byte)(IsBigEndian ? 1 : 0));
     writer.WriteBytes(Reserved, 0, 3);
 }
Example #3
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);
        }
 public void Write(UnityBinaryWriter writer)
 {
     writer.WriteStringToNull(UnityVersion);
     writer.WriteInt(TargetPlatform);
     writer.WriteByte((byte)(EnableTypeTree ? 1 : 0));
 }