I can provide a lot of details, but not a definitive answer as I haven’t succeeded in making this work as well as I’d like to.
The best reference I know is here:
There are also some useful hints in Richard Fine’s talk at the London Unity User Group’s 11th meeting - video here:
http://blogs.unity3d.com/2012/04/27/london-unity-usergroup-11/
So I’ve never had much success with this - it doesn’t behave how the documentation suggests. For example, private int fields seem to get serialized, but I haven’t had any success getting a custom type derived from UnityEngine.Object to serialize, whether the field is public or private, and regardless of use of the SerializeField attribute or the Serializable attribute. The reference just goes null. The inability to create my own serializable objects is the biggest barrier to this system being useful to me.
Overall you can still benefit from the runtime code updates if you’re careful, but you need to be able to reconstruct all unserializable data from serialized data and scene state, when it happens. The only method call you receive in this event is OnEnable - note that you also receive it in other circumstances. But you can design your class to have a set of serializable fields, and a set of unserializable fields whose values are derived from the serializable data and aspects of the scene (e.g. cached lookups of other components on the object, scene scans to find related GameObjects, etc).
When your component is initially created, on startup or as a result of loading a scene, or instantiating a prefab, the serializable fields will all be filled in but the unserializable data will be blank (zero, null, etc). Detect this state in OnEnable (not Awake or Start) and initialize the unserializable fields. Later calls to OnEnable don’t need to recreate all this data, in general, so you can avoid some overhead by checking an arbitrary field against null before repopulating everything.
So long as important persistent data is only stored in the serializable fields, this will also support code reloading, as Unity will serialize your state, unload and reload your assembly, and deserialize your state again - and all your components will get OnEnable called.
This doesn’t work for unserializable data that stores important variable game state - you need to avoid that. Note that lists of serializable types are serializable, but dictionaries are not - there’s only a small set of types which Unity blesses. If you could create your own objects that serialize correctly then this problem would go away, but as I said before, I didn’t have any success with that when I tried it, and no longer trust the documentation about it. So for now the best workaround I know of is to store the core data in serializable types and provide your own IDictionary wrapper around the raw data.
All in all it’s disappointing, and almost impossible to use properly. Maybe somebody else knows why I can’t create custom Unity-serializable types though - it would be great to know, as that’s the biggest stumbling block for me here.
The other big problem I’ve found with this is that coroutines get lost, and it’s pretty much impossible to resurrect them, unless they’re very basic.