I'm working on a turn based RPG and wanted to know whether its a good idea to use ScriptableObjects
as a way to store character data that will change at one point or another at runtime like stats, inventory items, spells & abilities, etc. I know that ScriptableObjects
are usually predefined and are used as read-only, so I wanted to ask around before I committed to it.
CodePudding user response:
ScriptableObjects
Are great for storing data at runtime, but if you want data to persist between sessions of your game, you're going to want to write the data to a file.
Application.persistentDataPath can be used to get a path to a place where you can save game data in files. You can then create a file and save your data in json format.
This would allow you to modify your scriptable objects at runtime, then when it comes to saving the game, convert them to json text and store your data in a text file.
Then when you open your game up again you can read this file and re-apply the data to your scriptable objects.
Just make sure all of your data is serialisable and it will work just fine.