[SOLVED] prefab mesh set to 'Missing (Mesh)' after play/stop

I made a prefab that uses a custom mesh from an fbx file. Every time I run the game and stop it again (by using the play button in unity), the custom mesh is not any more in the prefab (the value ‘Missing (Mesh)’ is displayed), and I have to set it again.

I tried removing the prefab and rebuilding it, but it didn’t resolve the issue.

I also tried using an other mesh from a different fbx file, but it also didn’t change anything.

I have other prefabs with custom meshes, but there there is no problem.

Does anyone know a workaround for this bug?

As a workaround, I created a factory method that sets the mesh (I’m calling this when I want to instantiate the prefab)

I’ve got the same issue and I’d like to know if it’s a known bug or if it’s just me screwing something up.

I’ve got a prefab called “BlackPawn” with a simple Cylinder as a Mesh. Somewhere in a script, i have a variable pointing to that prefab (using drag and drop from my assets to the variable in the inspector) :

var g_BlackPawn 	: GameObject;

And somewhere in the same script, i do :

var l_MeshFilter : MeshFilter = _Pawn.GetComponent( MeshFilter );
l_MeshFilter.mesh = g_BlackPawn.GetComponent( MeshFilter ).mesh;

_Pawn being another Game Object i generated.

And then, when i stop the game (CTRL+P), the BlackPawn prefab says its mesh is missing.

What’s wrong with what i’m doing ? I just want to retrieve the mesh of the prefab and give another GameObject the same mesh.

poke Any ideas ? I kinda need to get this done ASAP and I have no clue about what i’m doing wrong :frowning:

Thanks in advance,

Mael.

Instead of .mesh, try using .sharedMesh when getting mesh from prefab.
So: l_MeshFilter.mesh = g_BlackPawn.GetComponent( MeshFilter ).sharedMesh;

I have exactly the same problem, my meshfileter dissappears as soon as the game runs. I am however not using a prefab but an object mesh that I have created in an editor script. I tried playing with shared mesh but I had no luck. Any thoughts? It’s probably something to with editor scripts right?

meshes you create through code must be recreated on each run again unless you have code that stores them in a supported model format so unity can import them as real mesh.
dynamic assets run throuhg code only exist until the scene is unloaded (just as a warning: this also holds ingame, DontDestroyOnLoad does not change this fact!)

Ah ha. Now that makes sense then cheers!

So how would I go about storing my mesh as a model format?

…actually I guess my best bet would be to just build the mesh in my 3D package. That will save a lot of grief by the sounds of things. :slight_smile: