# Introduction

[Runtime Serialization (RS) for Unity](http://bit.ly/1Js1oTb) is a extremely easy to use and insanely powerful serialization tool specially made for Unity. Internally it makes use of Binary Format for serialization. Its really fast, super efficient and extremely easy to use. It can be used to serialize and deserialize c# objects as well as Unity objects. Yes, you heard it right!!! as a matter of fact, it can even be used for Scene Serialization, click [here](http://bit.ly/1PtuczK).

Its been a month, since its release and we are really thankful for feedback, suggestions from [Unity Community](http://bit.ly/1PQWG1a). Over the next few weeks, we've planned to write about our plugin and its usage. Currently planned topics are as follows:

* [Introduction](https://voxelbusters.gitbook.io/runtime-serialization/master)
* [How to serialize objects (Part 1)](https://voxelbusters.gitbook.io/runtime-serialization/how-to-serialize-objects-part-1)
* [How to serialize objects (Part 2)](https://voxelbusters.gitbook.io/runtime-serialization/how-to-serialize-objects-part-2)
* [How to serialize objects (Part 3)](https://voxelbusters.gitbook.io/runtime-serialization/how-to-serialize-objects-part-3)
* [Save Serialization Data](https://voxelbusters.gitbook.io/runtime-serialization/saving-serialization-data)
* [Serialization Callbacks](https://voxelbusters.gitbook.io/runtime-serialization/callbacks)
* [Supported Unity and System types](https://voxelbusters.gitbook.io/runtime-serialization/supported-types)
* [Limitations](https://voxelbusters.gitbook.io/runtime-serialization/limitations)

## Product Info

NameSpace: [VoxelBusters.RuntimeSerialization](http://voxel-busters-interactive.github.io/Runtime-Serialization/Documentation/DoxygenOutput/html/namespace_voxel_busters_1_1_runtime_serialization.html)\
API Interface: [RSManager](http://voxel-busters-interactive.github.io/Runtime-Serialization/Documentation/DoxygenOutput/html/class_voxel_busters_1_1_runtime_serialization_1_1_r_s_manager.html)\
Links: [Documentation](http://bit.ly/1FwtsFe) | [Asset Store](http://bit.ly/1Js1oTb)

## Serialization Explained

When Application is in active state, all the object-data are stored in memory. But there comes a time when user quits your application and all its data are released from memory. This flushing of data, causes application to loose all its progess, which definitely isn’t ideal for any type of application. And this is where the concept of Serialization dives-in for rescue, i.e., we can completely avoid data loss by saving a copy of application data onto disk and use the same saved data for restoring objects back to memory, when application is relaunched.

Serialization is a process of converting object-data into binary stream and saving onto disk. Whereas deserialization does exactly the opposite i.e, it restores object from formerly saved binary stream. Although, Unity’s PlayerPrefs can be used for this purpose, but it is limited to saving datatypes int, float, string. But the problem is, it can be troublesome and error prone when using it for complex objects. And adding to it every application has its own serialization requirement. So we wanted to come up with a generic solution which is capable enough to handle serialization of any complex object and thats how we ended up with Runtime Serialization for Unity.

When an object is serialized, the name of the class, the assembly and all the data members of that class instance are written to storage disk. Often, objects store references to other instances in member variables. When the class is serialized, RS tracks object references that were already serialized and thus it ensures that the same object is not serialized more than once. This makes it possible to maintain object references even after deserialization. One more advantage of tracking references is it helps us to handle circular references as well. The only requirement for object graph to be serialized is, class should be marked [RuntimeSerializable](http://bit.ly/1M9Gqv6). Incase, if you try to serialize a non [RuntimeSerializable](http://bit.ly/1M9Gqv6) class, then serialization fails and appropriate warning messages are thrown. When the [RuntimeSerializable](http://bit.ly/1M9Gqv6) class is deserialized, the object is recreated and the values of all the data members are automatically restored.

## Setup

For those who dont own a copy yet! Download it from [Unity Asset Store](https://www.assetstore.unity3d.com/en/#!/content/36879). And then, import the package into your project and thats it! now you are ready to use it.
