Serialization in-depth
summary
Explains why editor-window data vanishes on assembly reload: Unity extracts managed object fields into the C++ side, tears down managed memory, reloads assemblies, then reinjects serialized data. Demonstrates failing examples (plain class, user structs losing the float), fixes with [Serializable] and [SerializeField], shows that plain class references get duplicated on deserialize while scriptable objects preserve reference identity if created with CreateInstance and managed with hideFlags. Covers arrays vs. polymorphic lists (base-typed lists lose data), sub-assets via AssetDatabase.AddObjectToAsset, and custom editors/property drawers (Unity 4 feature) that work as shown.
AI-written summary · about
chapters (20)
- 0:00Introduction to serialization
- 1:50Understanding assembly reload
- 3:26Case study: simple classes
- 5:00Rules for class serialization
- 6:15Structs and serialization
- 7:43Class references and data loss
- 9:19Using Scriptable Objects
- 11:29Scriptable object rules
- 13:09Initialization order
- 15:28Hide flags and object visibility
- 18:38Serializing arrays and lists
- 20:20Polymorphic serialization issues
- 22:14Complex hierarchies
- 24:05Creating and using assets
- 27:03Customizing the editor GUI
- 29:40Property drawers
- 32:44Connecting assets to the game
- 35:00Sub-assets and organization
- 37:39Asset hierarchy and conclusion
- 39:43Q&A session








