Page 1 of 1

Loading ScriptablesObjects returns null

Posted: Sun Jul 10, 2022 3:58 pm
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

Re: Loading ScriptablesObjects returns null

Posted: Mon Jul 11, 2022 9:16 am
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

Re: Loading ScriptablesObjects returns null

Posted: Mon Jul 11, 2022 1:11 pm
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

Re: Loading ScriptablesObjects returns null

Posted: Mon Jul 11, 2022 1:18 pm
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

Re: Loading ScriptablesObjects returns null

Posted: Mon Jul 11, 2022 1:39 pm
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,