"Manager is required" warning from EditorWindow?

Discussion and help for Easy Save 3
Post Reply
jjjj
Posts: 3
Joined: Mon Sep 26, 2022 1:20 am

"Manager is required" warning from EditorWindow?

Post by jjjj »

Hi, is there a proper way to use the serializer in an EditorWindow script?

So I've got an EditorWindow which has a button, and when pressed, will run

Code: Select all

ES3.Serialize(myScriptableObject)
But this gives me the error:
InvalidOperationException: An Easy Save 3 Manager is required to load references. To add one to your scene...
I can fix it by creating a Manager in the scene that I have open, but that doesn't seem right because it makes the EditorWindow dependent on the opened scene having the Manager attached.

Is there a better way to handle this?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: "Manager is required" warning from EditorWindow?

Post by Joel »

Hi there,

UnityEngine.Object types (such as ScriptableObjects) are saved by reference and value. For this reason a reference manager is required, which must exist in a scene, as Easy Save is intended as a runtime serialiser, not an Editor serialiser (though some do use it as the latter).

The solution to this would be to only save value types, or save your data by value (to eliminate the need for a reference manager). The easiest way to do this is to provide an ES3Settings object as a parameter with the referenceMode and memberReferenceMode set to ES3.ReferenceMode.ByValue. I.e.

Code: Select all

var settings = new ES3Settings();
settings.referenceMode = ES3.ReferenceMode.ByValue;
settings.memberReferenceMode = ES3.ReferenceMode.ByValue;
var bytes = ES3.Serialize(ScriptableObject.CreateInstance<TestSO>(), settings);
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jjjj
Posts: 3
Joined: Mon Sep 26, 2022 1:20 am

Re: "Manager is required" warning from EditorWindow?

Post by jjjj »

Thanks Joel, that has addressed my issues.

Is there documention for the reference and member reference mode options? Couldn't seem to find it in the doco website.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: "Manager is required" warning from EditorWindow?

Post by Joel »

Hi there,

We don't actively advertise these as we've found that very often it's difficult for people to understand the implications of saving by value vs by reference, even if the implications are documented. Instead we only suggest this if someone contacts us directly so that we can describe the implications to them for their specific use case if they run into issues.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jjjj
Posts: 3
Joined: Mon Sep 26, 2022 1:20 am

Re: "Manager is required" warning from EditorWindow?

Post by jjjj »

No problem. Thanks for your help!
Post Reply