InvalidOperationException: An Easy Save 3 Manager is required to load references.

Discussion and help for Easy Save 3
Post Reply
jleven22
Posts: 8
Joined: Wed Jan 27, 2021 5:32 pm

InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by jleven22 »

Have been using ES3 for everything from variables to arrays without an ES3 Manager. Now I'm trying with a list and for some reason I'm getting that error. I would prefer not have this in all of my scenes. I could add, very simple, just trying to understand why it's happening, because I'd like to have less in my scene if possible.

Code: Select all

InvalidOperationException: An Easy Save 3 Manager is required to load references. To add one to your scene, exit playmode and go to Assets > Easy Save 3 > Add Manager to Scene
ES3Internal.ES3JSONReader.Read_ref () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:544)
ES3Types.ES3ComponentType.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ComponentType.cs:58)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:54)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:249)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:278)
ES3Types.ES3ListType.Read (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ListType.cs:64)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:274)
ES3Reader.Read[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:197)
ES3.Load[T] (System.String key, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:371)
ES3.Load[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:336)
DataSaveLoad.LoadLevelStart () (at Assets/Scripts/System/DataSaveLoad.cs:126)
LevelManager.Start () (at Assets/Scripts/System/LevelManager.cs:53)
What am I doing wrong here?

Code: Select all

//Load

        if (ES3.KeyExists("Available Guns"))
        {
            DataManager.instance.availableGuns = ES3.Load<List<Ranged>>("Available Guns");
        }
        
//Save
        ES3.Save("Available Guns", DataManager.instance.availableGuns);

User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by Joel »

Hi there,

As the error suggests, an Easy Save 3 Manager is required when you're saving or loading reference types.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jleven22
Posts: 8
Joined: Wed Jan 27, 2021 5:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by jleven22 »

I did actually go ahead and add it to the scene, and my other scenes. I still get the same error.

I do question needing it though - the other calls have gone swimmingly. Is it something about lists that requires the manager to be added?
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by Joel »

Hi there,

How did you add the manager to your scene? If you're still getting the error and you've added it via Assets > Easy Save 3 > Add Manager to Scene, please could you create a new project with a basic scene which replicates it and private message it to me?

As mentioned before, the manager is required if you're saving reference types (particularly UnityEngine.Object references). The error you pasted suggests that you're saving a Component, or an object which has a Component field.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jleven22
Posts: 8
Joined: Wed Jan 27, 2021 5:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by jleven22 »

Yup, ok, I had a lot of research to do before getting back to you. I understand now.

Now here's a feature question I have: Can I remove references from the reference manager? For instance, if I only wanted to include the weapons in my game, because I don't need to save and load everything else, could I only add those to the manager? If so, how?

Thank you for the prompt responses. I swear I'm almost done setting this tool up across my game. It really is helpful and I appreciate its existence!
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by Joel »

Hi there,

If you want to manage references yourself, you can go to Tools > Easy Save 3 > Settings and uncheck Auto Update References. Then if you delete the Easy Save 3 Manager and re-add it to your scene, this will ensure that any existing references are removed.

You can then right-click objects you want to add to the manager and select Easy Save 3 > Add Reference to Manager.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jleven22
Posts: 8
Joined: Wed Jan 27, 2021 5:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by jleven22 »

OK I did that and have made some progress.

That said, I am running into a new issue with ES3. First off, it doesn't appear that the save manager is adding the content to either the actual list nor the gameobjects themselves to the correct parent.

Image

Image


Here is how I'm loading:

Code: Select all

    public void LoadWeapons()
    {
        if (ES3.KeyExists("Available Guns"))
        {
            PlayerController.instance.availableGuns = ES3.Load<List<Ranged>>("Available Guns");
            //DataManager.instance.availableGuns = ES3.Load<List<Ranged>>("Available Guns");
        }
    }

I'm guessing this has something to do with the LoadInto function, but tbh I don't understand how that's supposed to work. The example documentation is light on that page. Is this something you can enlighten me on?

Even if I was able to get it under the right parent, I still don't see why it wouldn't update the PlayerController.instance.availableGuns list?

Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by Joel »

Hi there,

I'm afraid I don't understand the issue. Please could you create a new project with a basic scene which replicates it and private message it to me with instructions?

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

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jleven22
Posts: 8
Joined: Wed Jan 27, 2021 5:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by jleven22 »

Unfortunately I don't think it's going to be simple enough for me to just create a new project. Mine is a little more complicated for that.

However let me just kind of start from the top and lay out what's going down a little more clearly.

Basically I have a weapon pickup and a player. Once the weapon is picked up it does a few things:
- Adds the Ranged reference to the List of availableGuns
- Clones that weapon under the player parent object

So I'm using ES3 in the following way:
- I've added the save manager to all my scenes, and added in the references for all of the weapons and their components
- I save the List of availableGuns
- End the scene
- I load availableGuns

Here are the issues I'm finding:
- After loading, the availableGuns list is not updated to the state it was saved in, but reverts back to its original unsaved state
- The cloned weapon gameObjects are showing up with this name in the hierarchy "Easy Save 3 Loaded GameObject" and they are not under the Player parent object, just out in the open
- When I look in the inspector info for that weapon object ^^ I see this message:

Code: Select all

This GameObject was created because Easy Save could not find a GameObject in the scene with the same name instance ID as the GameObject the Component we are loading is attached to. To prevent this from being created, use the Load Into methods to tell Easy Save what Component the data should be loaded into.
So what I was asking was what the above message means? I don't understand what it's asking for. And the documentation is a bit light for me to understand.

Code: Select all

// Load a Transform from a key in a file into an existing Transform component.
ES3.LoadInto("myTransform", this.transform);
How does this load the list? How does it add the right transforms under the the List availableGuns? It doesn't seem comprehensive enough.

This is how I'm loading currently:

Code: Select all

    public void LoadWeapons()
    {
        if (ES3.KeyExists("Available Guns"))
        {
            PlayerController.instance.availableGuns = ES3.Load<List<Ranged>>("Available Guns")
        }
    }
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException: An Easy Save 3 Manager is required to load references.

Post by Joel »

Hi there,

The message you are getting means that a Component is being loaded, but the GameObject it's supposed to be attached to does not exist. This will happen for example if your GameObject is instantiated at runtime, and you load the Component before loading the GameObject which it belongs to.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply