Loaded GameObject does not load the Mesh.  Topic is solved

Discussion and help for Easy Save 3

Loaded GameObject does not load the Mesh.

Postby MASC » Wed Nov 27, 2019 2:24 pm

I don't know if I'm doing something wrong.
MASC
 
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm

Re: Loaded GameObject does not load the Mesh.

Postby Joel » Wed Nov 27, 2019 7:28 pm

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 Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2552
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loaded GameObject does not load the Mesh.

Postby MASC » Wed Nov 27, 2019 8:27 pm

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.

Postby MASC » Wed Nov 27, 2019 9:54 pm

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.
MASC
 
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm

Re: Loaded GameObject does not load the Mesh.  Topic is solved

Postby Joel » Thu Nov 28, 2019 7:57 am

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 Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2552
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loaded GameObject does not load the Mesh.

Postby MASC » Thu Nov 28, 2019 5:01 pm

Thank you! :D
MASC
 
Posts: 7
Joined: Wed Nov 13, 2019 10:09 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron