Save Scriptable Object

Discussion and help for Easy Save 3
Post Reply
Johnny Star
Posts: 29
Joined: Sat Mar 21, 2020 2:17 pm

Save Scriptable Object

Post by Johnny Star »

Hello, I'm trying to find a tutorial specifically targeted towards Scriptable Objects, but can't seem to find any.

I have an inventory system that uses a list to store items into it.
Image

The items are Scriptable Objects too. So what I had in mind was:
1) Get the list of items and references, save them normally where everything else is saved to by default (at the persistent data path).
2) Empty the list of the Scriptable Object inventory on application quit.
3) On load, get the inventory system SO and repopulate it with the list of items that were saved.

The question is: Is this the way to do it? Or is there another way ES3 does the saving of Scriptable Objects?
I'm also new to this so please let me know if there's anything that I should look out/be aware of.

Thank you!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save Scriptable Object

Post by Joel »

Hi there,

ScriptableObjects are generally saved and loaded like any other data, though be aware that they are saved by reference when you save a script which has a ScriptableObject field.

So in your case I would generally save all of the Items in a List or array, and then save the BagInventory. Then when you come to load, load the List of Items first, and then load the BagInventory.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply