Saving a Mesh only saves a Reference

Discussion and help for Easy Save 3
Post Reply
amasinton
Posts: 4
Joined: Mon Apr 01, 2019 1:22 pm

Saving a Mesh only saves a Reference

Post by amasinton »

Easy Save has been a fantastic asset, saves tons of time and is easy to use. Well done!

I'm running into an issue trying to save and load a mesh. It's saving a reference to the mesh but not the mesh data itself.

Some background: I have created a small data-holder class to save a set of data all together, including a mesh. I have successfully created a custom Easy Save type for this class. When I trigger a save, it writes the save file as anticipated. In that file I can see that it has saved the other data in the class correctly, but for the mesh I get something like this: "myMesh":{"_ES3Ref":6654615124156248822}. When I trigger a load, all of the other data in the class is loaded correctly but the mesh field is blank.

On June 11, 2018, davidiad posted a similar issue when saving meshes via cloud storage. At that time it was suggested a fix was available. I'm hoping this still holds true.

Thanks for your help!
User avatar
Joel
Moodkie Staff
Posts: 4899
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a Mesh only saves a Reference

Post by Joel »

Hi there,

Fields of reference types are stored by reference, so this is expected behaviour.

If you want to save the mesh by value, you can either save it separately using ES3.Save, or you can create an ES3Type file for the class containing your Mesh field and modify it so that it saves by value.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
amasinton
Posts: 4
Joined: Mon Apr 01, 2019 1:22 pm

Re: Saving a Mesh only saves a Reference

Post by amasinton »

Thank you for your quick response, Joel.

I have created an ES3Type file for the class containing the mesh. In that file I see that the mesh is set to WritePropertyByRef, so I have changed that to WriteProperty. However, the save file still only writes the reference.

I have also tried saving the MeshFilter rather than the Mesh directly. The save file generated in this case saves a reference to the MeshFilter then also saves a reference to the "sharedMesh" of that MeshFilter. So, still saves the mesh by reference.

The ES3Type_Mesh file lists all of the properties of a Mesh which suggests that this ES3Type is capable of writing out the values each of these properties, but I don't understand why it just writes the reference rather than all of these property values defined in the ES3Type_Mesh class.

So, I guess I'm asking how do I tell ES3 to write mesh by value?

Thanks for your help!
User avatar
Joel
Moodkie Staff
Posts: 4899
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a Mesh only saves a Reference

Post by Joel »

Hi there,

That's strange, it should work. Please could you PM me a very basic project which replicates this, with your ES3Type?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
amasinton
Posts: 4
Joined: Mon Apr 01, 2019 1:22 pm

Re: Saving a Mesh only saves a Reference

Post by amasinton »

PM'ed with sample project.

Thank you!
amasinton
Posts: 4
Joined: Mon Apr 01, 2019 1:22 pm

Re: Saving a Mesh only saves a Reference

Post by amasinton »

Joel took a look and guided me to the solution.

So, for anyone else experiencing this, here's Joel's solution:

"It turns out that it was something obvious, but something I missed. In the settings, the member reference mode was still set to save by reference. This option isn't actually exposed in the Editor, but you can change this directly by going to Assets/Plugins/Easy Save 3/Resources/ES3, opening the ES3 Default Settings prefab, and in the ES3DefaultSettings component set the Member Reference Mode to "By Value"."

Hope this is helpful to others, too!
Post Reply