_ES3Ref refers to wrong object

Discussion and help for Easy Save 3
Post Reply
Toreth27
Posts: 3
Joined: Sun Jan 16, 2022 4:02 pm

_ES3Ref refers to wrong object

Post by Toreth27 »

I've run into a problem several times where it seems like Easy Save is referencing the wrong object in saved games, so when it tries to load the game I get an error like

Code: Select all

Unable to load saved game: System.ArgumentException: 
Object of type 'UnityEngine.Sprite' cannot be converted to type 'CaptureTheFlag.Agents.Anatomy.BodyType'
Here is a screenshot showing how the types are incorrect. The Ease Save reference ID should be referring to a CaptureTheFlag.Agents.Anatomy.BodyType object (which is a ScriptableObject), but instead Easy Save seems to be referencing a Sprite object.

https://imgur.com/YQNhzn8

This problem has happened several times at different points in my development, and I haven't been able to figure out what is happening within Unity that is causing this problem. When it happened this most recent time, I had disabled some SpriteRenderers in my game prior to saving, but I'm not sure if that was just a coincidence of if that has something to do with this problem. My guess is that Easy Save is changing what objects its _ES3Ref values (from the save file) refer to, but I don't know why it would be doing that.

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

Re: _ES3Ref refers to wrong object

Post by Joel »

Hi there,

The only case it would do this is if you changed the type of a field so that it no longer matches the type of the Save data, or if you manually set the same ID to be the same as another object. If it’s the former, you would need to remove your previous save data (Tools > Easy Save 3 > Clear PersistentDataPath).

If this doesn’t resolve the issue, please could you replicate this in a new project with a simple scene and private message it to me with instructions.

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

Toreth27
Posts: 3
Joined: Sun Jan 16, 2022 4:02 pm

Re: _ES3Ref refers to wrong object

Post by Toreth27 »

Hi Joel - it looks like I can reproduce the problem by adding another component to a prefab in my game. Does that cause the entire reference dictionary to be rebuilt, and thereby break all saved games?

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

Re: _ES3Ref refers to wrong object

Post by Joel »

Hi there,

I‘ve had no reports of this happening and this doesn’t appear to be happening at my end. Are you using the latest version of Easy Save?

If so, could you provide steps to replicate this in a new project?

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

Toreth27
Posts: 3
Joined: Sun Jan 16, 2022 4:02 pm

Re: _ES3Ref refers to wrong object

Post by Toreth27 »

Hi Joel - I'm trying to create a sample project to recreate this error, but so far I haven't been able to recreate it. Is there a way to look up a reference in the ES3 Reference Mgr component based on an ID (there are thousands of references in it, so I can't look manually)? I want to see which component the _ES3Ref reference which is causing the error is pointing to, and see if I can identify a point at which the reference ID points to the wrong thing or if the error occurs even though the reference is correct.

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

Re: _ES3Ref refers to wrong object

Post by Joel »

Hi there,

Currently the way to do this would be using ES3ReferenceMgr.Current.Get(id) in an Editor script to output the value to console.

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

Post Reply