Proper way to save scriptable objects/read save file

Discussion and help for Easy Save 3
Post Reply
syu15
Posts: 16
Joined: Thu May 13, 2021 1:05 am

Proper way to save scriptable objects/read save file

Post by syu15 »

Hello,
I have a prefab with a script on it which is referencing some scriptable objects. The nested data in the scriptable object is being modified during gameplay and then I am saving the script when the game quits. Since scriptable object data persists after play mode has exited, I am having trouble figuring out if the scriptable objects are being saved by Easy Save or not. When I open up the JSON save file, I only see hashes next to the scriptable objects like so:

Code: Select all

	{
		"__type" : "FurnitureHelper,Assembly-CSharp",
		"_ES3Ref" : "5823137606146563824",
		"goID" : "8201234751940344136",
		"FloorFurniture" : {
			"_ES3Ref" : "9139268332010462639"
		},
		"BedFurniture" : {
			"_ES3Ref" : "110543471606065824"
		},
		"WallLFurniture" : {
			"_ES3Ref" : "3740186123906972086"
		},
		"WallRFurniture" : {
			"_ES3Ref" : "5631097052467397900"
		}
	}
Does that mean that the nested data inside the scriptable object isn't getting saved or is that to be expected? If so, is there a way to see what is getting saved inside of the scriptable object? They do have nested classes/fields inside of them but I have generated a separate type for those as well so I thought I was doing that correctly.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Proper way to save scriptable objects/read save file

Post by Joel »

Hi there,

Fields of UnityEngine.Object types are saved by reference. If you want to save them by value you should either save them using separate ES3.Save calls or put them into an array and save that.

For more information on what gets saved and how, please see the Supported Types guide:
https://docs.moodkie.com/easy-save-3/es ... ted-types/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
syu15
Posts: 16
Joined: Thu May 13, 2021 1:05 am

Re: Proper way to save scriptable objects/read save file

Post by syu15 »

Ok, thanks for the explanation!
Post Reply