12

Saving and Loading Profiles

Saving and loading user data can be handled in many ways. For example, you might just store everything in a static class and dump it out to a .json file whenever you need to. Perhaps you want to use .xml format files, or even a database? In this chapter, we will look at a method for saving and loading user data that uses a ScriptableObject combined with .JSON for its format. The ScriptableObject contains an array of instances of a data class named ProfileData. The ProfileData class holds everything we want to save and load to Profiles. By using an array of ProfileData in the ScriptableObject, we can easily load, and save to more than one save profile.

The system in this chapter works with save slots, although ...

Get C# Game Programming Cookbook for Unity 3D, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.