# How to Serialize Objects (Part 3)

Hello again, lovely people! Last month, I wrote couple of blog posts regarding serializing custom class as well the ones which belong to external assembly. Well let’s go ahead and explore a bit about serializing custom classes that inherit properties from external class. Lets call these types as Hybrid Classes.

**What is Hybrid Classes?** As said above, hybrid classes are the custom scripts that inherit properties from the classes which belong to External Assembly. Most popular example for this would be custom Mono components. Most of us would have used it while developing games. Here custom script derives properties from MonoBehaviour class which actually belongs to external assembly UnityEngine .

**How to serialize Hybrids?** In order to serialize Hybrids properly, we need to tell RS system to serialize defined properties as well as serialize external parent class properties using Extension. This sounds bit tricky, but actually just a single line definition using RuntimeSerializable attribute will do this job.

Following example shows how to serialize hybrids using [RuntimeSerializable ](http://voxel-busters-interactive.github.io/Runtime-Serialization/Documentation/DoxygenOutput/html/class_voxel_busters_1_1_runtime_serialization_1_1_runtime_serializable_attribute.html#ae55096cbc6b4da9974bf052598d4eb8f)attribute.

```
using UnityEngine;
using System.Collections;
using VoxelBusters.RuntimeSerialization;

[RuntimeSerializable(typeof(MonoBehaviour))]
public class CustomMonoBehaviour : MonoBehaviour 
{
    ....
    ....
    ....
}
```

While serializing an object, RS starts off finding out the properties that are asked to be serialized. And this is done by iterating through each level of class hierarchy and gathering serializable property information. And on declaring Extension dependency in Following example shows how to serialize hybrids using [RuntimeSerializable ](http://voxel-busters-interactive.github.io/Runtime-Serialization/Documentation/DoxygenOutput/html/class_voxel_busters_1_1_runtime_serialization_1_1_runtime_serializable_attribute.html#ae55096cbc6b4da9974bf052598d4eb8f) attribute, it basically tells RS that MonoBehaviour behaviour properties can’t be serialized directly instead we are supposed to use Extension for it.

Also, you might be already aware about Unity restriction related to MonoBehaviour object creation i.e, new object instances can’t be created using new operator. But instead we need to use GameObject.AddComponent method call for creating new instances. Considering this restriction, our Extension stores few extra metadata which will be used at point of deserilization for creating instances. So incase if you miss specifying extension dependency, then firstly properties related to external parent class won’t be serialized and other thing is you will get few errors as object creation might fail at runtime.

And of course, this applies to serialization to custom objects which use non Unity assembly classes as well.

We just touched upon serialization of Hybrid Classes and if you have any doubts, please feel free to ask.
