OnBeforeSerialize()
Implement this callback to transform data into serializable data types immediately before an object is serialized.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
void OnBeforeSerialize()
Remarks
Unity invokes the callback on an object before serializing it. In this callback, you can transform your data into something Unity understands. For example, to serialize a C# , copy the data from the object into an array of keys and an array of values.
OnBeforeSerializeDictionaryDictionaryRefer to Custom serialization in the Manual for more information.
Note: Unity calls before recompiling scripts in a domain reload, so any changes made to code in this method won't take effect until the second invocation of the callback following the change, in other words after a full serialization and domain reload cycle. For more information, refer to Details of disabling domain and scene reload in the Manual.
OnBeforeSerialize