I’ve been looking around and can’t find a definitive answer, so I decided to make a thread.
Basically I have a game where you can create your own objects (similar to besiege) and I need an easy way to store your created objects, this includes all the components on the children. I’ve looked at quite a few assets on the store, however they only seem to store variables similar to playerprefs (Bool, Int, float, string etc).
I’ve started looking into the Unity serializer but am not sure about it; ideally there would be a method which is as easy as simply creating a prefab, but afaik there isn’t.
Sure, you can create a prefab at runtime, however once the game is exited or closed this prefab will revert to an empty prefab, simply because Unity can’t do it Also the prefab thing is an UnityEditor function, so once built I don’t think prefabs even have functionality.
I had this problem a while ago and used UnitySerializer for a while. It is powerful, but also no longer supported and the website with all the Scripting API and forum full of helpful and sometimes critically important information is offline. Hence I dived into the fairly complex topic of serialization via BinaryFormatter and Reflection, and wrote my own framework for saving and loading a GameObject with all it’s components. Currently, it can load and save any kind of data you want along with complete GameObjects with their Transform information as well as MonoBehaviour scripts on them. Support for other Unity-specific components like renderes etc. are not included as they are often just not needed; It’s easy to write your own function for that, however. The asset is free and is described in more detail in this thread, and the scripts included are also commented comprehensively so it’s easy to understand what’s going on so users can modify it further.