Save Scriptable Object

Discussion and help for Easy Save 3

Save Scriptable Object

Postby Johnny Star » Sat Mar 21, 2020 5:22 pm

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!
Johnny Star
 
Posts: 1
Joined: Sat Mar 21, 2020 2:17 pm

Re: Save Scriptable Object

Postby Joel » Sun Mar 22, 2020 8:31 am

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
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2688
Joined: Wed Nov 07, 2012 10:32 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron