I am building a level editor for my game.

This means that I have to be able to:

  1. serialize a GameObject, all of its children and all of their components to an XML file
  2. load them back into the core game

I have read thread after thread about serialization, but I can’t seem to find the right one. It’s always about just saving the game. Is there a good way to completely serialize a GameObject and all of it children, top to bottom?

If you want to know why I am doing this, it’s because I want my game to eventually become a moddable community project, and I don’t want to require every contributor to have a Unity license. Furthermore, it facilitates the whole project structure if I can use files that are external from the core build. I generally find the package approach extremely limiting. And last, but not least, I want to enable contributors to make game content in Linux, which the Unity Editor currently does not :slight_smile:

Any help on this is highly appreciated. Thank you in advance.

EDIT:
I have been reading about ISerializationSurrogate, is it possible that this might be my salvation?

I was very inspired by the Unity Serializer by whydoidoit, but I actually ended up writing my own serializer based on the JSONObject class. The Unity Serializer is very good for serializing everything, but if you are just moving around some prefabs, I’d recommend rolling your own.

You can use Unity Serializer to do that. It supports individual objects and whole games - but it only support compressed binary and JSON formats.

GameObject Serializer Pro can serialize entire GameObjects, their children, and their components.

Currently the supported types list supports only some of the most common types like meshes, transforms, etc, but I can add more types as there is demand for them.

You can directly serialize GameObject using our plugin Runtime Serialization for Unity. Its not just another serialization plugin which works only on custom c# objects. But what makes it special is its capablity to serialize Unity Objects like GameObject, MonoBehaviours, Textures, Prefabs etc. As a matter of fact, you can even use it for Scene Serialization. For more info about supported list, please check this 2.