Pigeon shit

[ Pigeon shit ] Unity data persistence

Hello there, been a while..
I have been working on the data persistence of the game, the choice was made to do local storage and if feasible online storage (in the cloud~). After a short research I had found the following possiblities:

Playerprefs
The most easy and standard used solution. Playerpres supports:

get/set floats
get/set ints (booleans are possible if you convert them to integers ea 0-1).
get/set strings

– Writing / reading  XML / JSON formats
I don’t think I’ll pick this one, the format is very human readable and players could mess with it to cheat.

Serialization
With this we can write and read whole classes with nested classes etc in them and is safer than XML/JSON because it’s less readable. Serialization supports:

custom non abstract classes with [Serializable] attribute.
custom structs with [Serializable] attribute. (Added in Unity 4.5)
references to objects that derive from UnityEngine.Object
primitive data types (int, float, double, bool, string, etc.)
array of a fieldtype we can serialize
List<T> of a fieldtype we can serialize

Google play games services API
this can be used to do the online-cloud storage of our game data so the players data is linked with their play store account and his/her progress is linked on multiple devices.
Have to look more into this in the future when we integrate google play.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>