Data persistence in our application

In the previous chapter, we implemented most of the logic of our application. However, every time the user closes the application, all their tasks disappear. This is because our application is not persisting data.

To make data persistent, we need in some way to store it. The first intuitive way is to store the data locally, which means saving to a file.

PlayerPrefs in Unity

Unity offers a quick and easy way to store data persistently by using PlayerPrefs, a special class where there are functions to save primitives, such as integers or strings. In the following examples, we will work with strings, but the process is the same for all the other primitives.

The Set function

It is possible to save the data by using the ...

Get Gamification with Unity 5.x 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.