• The TransformData class is the serializable primitive object storing the raw transform data extracted from the transform component. However, for the JSON serializer, we'll use the Vector3 and Quaternion data types, as these serialize to a file without issues.
  • In the Awake function, all transform components are found using the Object.FindObjectsOfType function. This generates an array of found transform components in the TransformArray class variable.
  • The SaveData function is run to serialize all transform components in the scene to a specified JSON file in Application.persistentDataPath. This method only serializes all objects currently in the scene, and it assumes that each object has a unique name.
  • The SaveData function begins ...

Get Mastering Unity 2017 Game Development with C# - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.