Serialization and scripting
To finish with our theory for this chapter, we need to cover serialization in Unity. Now, Unity already serializes just about everything from the editor to your scene automatically (with a few exceptions) when it saves and loads the scene.
Note
There are a few fringe cases where Unity will not serialize some data. These cases have to do with the current limitations of the Mono 2 framework that Unity uses under the hood. A full explanation of what doesn't work can be found in the following article; note that it is very technical and includes a link to the error report in Unity where it is recorded: http://www.codingjargames.com/blog/2012/11/30/advanced-unity-serialization/
However, what if we want to actually use this serialization to our advantage within our game to save and load levels. We need bits of raw game data (or as we will continue with this later, saving conversations for our NPCs). To accomplish this, the best way is to use a Unity-inherited object named...