Page 1 of 1

Loaded GameObject does not load the Mesh.

Posted: Wed Nov 27, 2019 2:24 pm
by MASC
I don't know if I'm doing something wrong.

Re: Loaded GameObject does not load the Mesh.

Posted: Wed Nov 27, 2019 7:28 pm
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

Re: Loaded GameObject does not load the Mesh.

Posted: Wed Nov 27, 2019 8:27 pm
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

Re: Loaded GameObject does not load the Mesh.

Posted: Wed Nov 27, 2019 9:54 pm
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.

Re: Loaded GameObject does not load the Mesh.

Posted: Thu Nov 28, 2019 7:57 am
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

Re: Loaded GameObject does not load the Mesh.

Posted: Thu Nov 28, 2019 5:01 pm
by MASC
Thank you! :D