Saving Runtime Generated GameObjects to Prefabs

I’m creating new instances of GameObjects while in Play Mode that I’d like to save in Prefabs. I can manually drag them from the hierarchy view into the Asset view while in Play mode, but I’d like to do this from a script that I trigger while still in Play mode.

Is that possible?

This is all that you need:

Take a look az CreatePrefab method

How can you save the mesh file? I use the same method but the saved prefab don’t have the meshes.