Loaded GameObject does not load the Mesh.

Discussion and help for Easy Save 3
Post Reply
MASC
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm

Loaded GameObject does not load the Mesh.

Post by MASC »

I don't know if I'm doing something wrong.

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

Re: Loaded GameObject does not load the Mesh.

Post by Joel »

Hi there,

Please could you provide a bit more information? How are you saving and loading your Mesh? Are you saving and loading in the same scene or different scenes? Is the Mesh part of an object instantiated at runtime? Is it a procedural Mesh?

Also be aware that Meshes are loaded by reference, so if a reference to the Mesh does not exist in your scene, it will not be able to find it to be able to reference it.

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

MASC
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm

Re: Loaded GameObject does not load the Mesh.

Post by MASC »

Hi,

It's a procedural mesh.
The mesh is generated at runtime.

I inclusive tried to save the mesh apart but is saved with a null value.

MASC

MASC
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm

Re: Loaded GameObject does not load the Mesh.

Post by MASC »

Saving and Loading gameObjects instantiated at runtime with mesh generated at runtime (i.e. procedurally) too,

ES3.Save<Dictionary<string, GameObject>>(goDesignDictionaryString, designDictionary, "NewGameObjectFolder.es3");
ES3.Load<Dictionary<string, GameObject>>(goDesignDictionaryString, "NewGameObjectFolder.es3");

Trying to save Mesh from gameObject,

ES3.Save<Mesh>(this.gameObject.name, this.gameObject.GetComponent<Mesh>(), "MeshFolder.es3");

Everything Is in the same scene so far.

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

Re: Loaded GameObject does not load the Mesh.

Post by Joel »

Hi there,

Because the Mesh is generated at runtime, there will not be a reference to it between loads because it won't exist. Instead you will need to save it directly.

To save the Mesh you need to save the mesh of the MeshFilter, rather than trying to save a Mesh component. I.e.
ES3.Save<Mesh>(this.gameObject.name, this.gameObject.GetComponent<MeshFilter>().sharedMesh, "MeshFolder.es3");
All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

MASC
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm

Re: Loaded GameObject does not load the Mesh.

Post by MASC »

Thank you! :D

Post Reply