Version: Unity 6 Preview (6000.0)
Language : English
Script serialization errors
Plug-ins

Serialization best practice

You can organize your data to ensure you get optimal use of Unity’s serialization.

  • Aim to have Unity serialize the smallest possible set of data. The purpose of this isn’t to save space on your computer’s hard drive, but to make sure that you can maintain backwards compatibility with previous versions of the project. Backwards compatibility can become more difficult later on in development if you work with large sets of serialized data.
  • Never have Unity serialize duplicate data or cached data. This causes significant problems for backwards compatibility: it carries a high risk of error because data can get out of sync.
  • Avoid nested, recursive structures where you reference other classes. The layout of a serialized structure always needs to be the same; independent of the data and only dependent on what’s exposed in the script. The only way to reference other classes is through classes derived from UnityEngine.Object. These classes are separate; they only reference each other and they don’t embed the contents.
Script serialization errors
Plug-ins