Saving data - XML files
Both the PlayerPrefs
class and third-party INI file readers are useful for saving and loading miscellaneous settings, such as high score, resolution, and volume. For complicated data, such as the state of a level, the positions of objects, or an inventory of items, both PlayerPrefs
and INI files quickly become impractical. Instead, more robust storage solutions are needed. At this stage, we have three main options in Unity; namely XML files, binary files, and JSON files. In this section, we'll focus on XML, which refers to an HTML-like language for storing structured, hierarchical data in human-readable text. Here, we'll focus on saving and loading the position, rotation, and scale of all objects in the scene. In essence, this lets us save the complete state of a scene to a file. To start, let's begin with a scene containing some objects:
Building a scene filled with objects, ready for Serialization
Note
You can find a copy of the XML Serialization project in this...