missing mesh after creating prefab inside AssetPostprocessor . OnPostprocessModel ()

hey guys,
I have a skinned mesh FBX file and I want to create a prefab of it on import .
Doing it in AssetPostprocessor.OnPostprocessModel() seems to almost work, except the mesh inside the SkinnedMeshRenderer component that is null.

I have tried to force reconnect the Mesh object after PrefabUtility.CreatePrefab() and it results in ‘missing (Mesh)’ but still it is not there. Odd part is that if I pause execution with a break point right after reconnecting the sharedMesh with :

SkinnedMeshRenderer tempMeshRenderer = prefab.GetComponentInChildren();
tempMeshRenderer.sharedMesh = mesh ;

it’s set correctly until the AssetPostprocessor finishes and then its missing.

What’s going on here?
Thank you

You need to create your prefab in OnPostprocessAllAssets(…), before that the game object you are manipulating is temporary. More info here: After AssetPostprocessor meshes seem to be gone. - Questions & Answers - Unity Discussions

(I added a reply to that answer i linked, not sure when it will appear)

I have the same problem too in editor. When i create the prefab all the meshes in the render component go missing.