Book Image

Mastering Unity 5.x

By : Alan Thorn
Book Image

Mastering Unity 5.x

By: Alan Thorn

Overview of this book

Mastering Unity 5.x is for developers wishing to optimize the features of Unity 5.x. With an in-depth focus on a practical project, learn all about Unity architecture and impressive animation techniques. With this book, produce fun games with confidence.
Table of Contents (16 chapters)
Mastering Unity 5.x
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

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...