- Home /
Serializing System.object or System.Type doesnt work. Data is lost.
Is there anything special I have to do to serialize System.object or System.Type, I've tried using [Serializable] and [SerializeField] but the data doesn't survive the assembly reload.
Is it even possible to serialize these types so that they'll survive the reload?
Answer by Adam-Mechtley · Feb 10, 2017 at 08:26 PM
No it is not possible to serialize these types. Please see the Serialization rules section of this page in the docs: https://docs.unity3d.com/Manual/script-Serialization.html
For something like a Type, the best alternative you have is to serialize the AssemblyQualifiedName as a string, though you'll probably want to create your own custom PropertyDrawer instead of having to type these in manually.
Your answer
Follow this Question
Related Questions
Serialization - Variables won't change on original construction 1 Answer
Serializing Properties (JSON saving and loading system) 2 Answers
Scriptable Object List values are always null 1 Answer
Load Objects from a specific directory into a list? 0 Answers
GetType is Monoscript, how to implement correctly? store type in variable? 1 Answer