serialization: If you do specify, Unity establishes the object as a managed reference.Then, when Unity deserializes the fields, they contain different distinct objects with identical data. This means that if you store a reference to an instance of a custom class in several different fields, they become separate objects when serialized. Inline serialization: By default, Unity serializes custom classes inline by value when you don’t specify on the field that references the class.There are two ways that this can happen: inline and by. But for custom classes which don’t derive from UnityEngine.Object, Unity includes the state of the instance directly in the serialized data of the MonoBehaviour or ScriptableObject that references them. Unity serializes the instance itself independently, so it isn’t duplicated when multiple fields are assigned to the instance. When you assign an instance of a UnityEngine.Object-derived class to a field and Unity saves that field, Unity serializes the field as a reference to that instance. Use serialization callbacks, by implementing ISerializationCallbackReceiver, to perform custom serialization.įor Unity to serialize a custom class, you must ensure the class:.Wrap the nested type in a class or struct.If you want to serialize these, you have two options: ![]() Note: Unity doesn’t support serialization of multilevel types (multidimensional arrays, jagged arrays, dictionaries, and nested container types).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |