- Home /
How to save game progress with scriptable object references?
Hello, I am making an rpg and I am storing the "base" item and character data in scriptable objects. That is the fixed data I don't want to be changed during run time and works fine.
Now I want to save the game progress, including the inventory contents and what characters are in the players party. I need to save some kind of reference that would allow me to, when loading saved game data, read some kind of identifier and get access to the scriptable object that contains the properties of the item or character.
I am considering using the name of the scriptable object as an identifier or adding an identifier field to the scriptable objects. However, that sounds prone to failure as it implies manual management.
Is there a better way? Are instanceIDs reliable identifiers though differente builds?
Answer by rob11 · Oct 26, 2019 at 02:40 AM
I came through the same problem a while ago. As you realized, we can't serialize scriptable objects. So to retrieve items for my player inventory I made a struct called InventoryMemory which has an ID and a Quantity (2 int), the ID retrieves the items he possesses from the item pool on my inventory system script. (an item array that has all the item I must manually drop in...) It works well for me so far but sure doesn't feel that robust. I plan to make an editor script that adds all my items in this array with the click of a button.
Seeing more than a week has passed without a better solution i'm going to mark this as accepted since it's the best aproximation, thank you for answering.
Your answer
Follow this Question
Related Questions
Using a Scriptable Object as a Config 0 Answers
Deep Copy of ScriptableObject 1 Answer
ScriptableObject reference resetted after a method is finished. 2 Answers
Giving a ScriptableObject asset reference to all instances of a MonoBehavior? 0 Answers
Show on ScriptableObject all other ScriptableObjects that reference it 0 Answers