- Home /
Saving players progress in ScriptableObject asset
Hi everyone!
I've been reading about ScriptableObjects lately and I find them very useful for storing static data like predefined level properties, ammo types, enemy type properties etc...
However, I was wondering can ScriptableObjects be used to save players progress? Is it recommended way to do it?
For example, I'd like to publish a game on iOS. A player will be able to solve levels and best time for each level will be saved. Where should I save players best times? Is it possible to have that information stored on a ScriptableObject named PlayerProgress in projects folder? Should that kind of information rather be kept on special place on disk like Application.persistentDataPath? Can it be done with ScriptableObject at all or does it have to be some kind of serialization or trough PlayerPrefs?
Thank you very much for your help!
Answer by cjdev · Aug 26, 2015 at 08:54 PM
You have various options when it comes to storing your game state and there's a good Unity tutorial about it here. The method you use is mostly dependent on the complexity and size of the information you need to save. If you just want to save a few variables about the player and maybe which level is the current one then player prefs might be ideal. If, on the other hand, you want to save hundreds or thousands of objects you might want to look at XML serialization and the XDocument and XElement classes. Ultimately, the recommended way to save the state of your game will depend entirely on the needs of your game.