Loading ScriptablesObjects returns null

Discussion and help for Easy Save 3
Post Reply
doodlinbee
Posts: 23
Joined: Sat Sep 05, 2020 12:53 pm

Loading ScriptablesObjects returns null

Post by doodlinbee »

Save function:

Code: Select all

    public void Save()
    {
        ES3.DeleteFile("Cache");
        ES3.Save("savedItem", savedItem, "tests", new ES3Settings(ES3.Location.Cache));
        ES3.StoreCachedFile("tests");
    }
Makes this save file:

Code: Select all

{
	"savedItem" : {
		"__type" : "InventoryItemSO,Assembly-CSharp",
		"value" : {
		"_ES3Ref" : "15922733832865706",
		"_ES3Ref" : "15922733832865706"
	}
	}
}
Load function:

Code: Select all

    public void Load()
    {
        ES3.CacheFile("tests");
        savedItem = ES3.Load("savedItem", "tests", SOLibrary.instance.item_Key_Blue, new ES3Settings(ES3.Location.Cache));
    }
I go into play mode, set the savedItem as the 'red key' scriptable object. Then exit and re-enter play mode. When I use the load function, it returns a null scriptable object
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading ScriptablesObjects returns null

Post by Joel »

Hi there,

This is likely because there isn't a reference to your ScriptableObject in your scene prior to runtime, so it's impossible to get a persistent reference to it. To resolve this, right-click the ScriptableObject and select Easy Save 3 > Add Reference(s) to Manager.

If this doesn't resolve your issue, please could you create a new project with a simple scene which replicates this and private message it to me with instructions.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
doodlinbee
Posts: 23
Joined: Sat Sep 05, 2020 12:53 pm

Re: Loading ScriptablesObjects returns null

Post by doodlinbee »

It doesn't seem to replicate on a new simple project.

Adding the individual SO's references to the manager didn't work. Adding the SO's script reference seem to work though which is weird because it didnt change anything in the save's output file.
Also why in the save file there's two times the exact same line ? "_ES3Ref" : "15922733832865706", it doesnt happen in the new project
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading ScriptablesObjects returns null

Post by Joel »

Hi there,

Unfortunately I wouldn't be able to understand why this is happening without being able to see a basic project which replicates it. Please could you take your original project, remove everything from it which isn't required to replicate it, and then private message it to me with instructions so I can see what is happening.

Also just to check, are you using the latest version of Easy Save?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
doodlinbee
Posts: 23
Joined: Sat Sep 05, 2020 12:53 pm

Re: Loading ScriptablesObjects returns null

Post by doodlinbee »

I have version 3.4.2, unfortunately my project is way too big and I won't have the time to work on this problem so I'll just do a workaround use my own way of referencing SO's.

All the best,
Post Reply