How to save a gameobject with script generated mesh?

hi, I have created a sphere by changing meshes of a cube, and I would like to save it as a prefab using this code :
GameObject Geo; Geo = new GameObject("myWorld"); MeshFilter GeoMesh = Geo.AddComponent<MeshFilter>(); GeoMesh.mesh = local; GeoMesh.sharedMesh = local; Geo.AddComponent<MeshCollider>(); Geo.AddComponent<MeshRenderer>(); PrefabUtility.CreatePrefab("Assets/World/myWorld.prefab", Geo); AssetDatabase.SaveAssets();

I only save the empty game object, without the mesh. I tried different things but I was never able to save the mesh with the game object.

You just need to create a prefab set up script with a reference to an empty prefab called MyWorld

 public GameObject myPrefab;
  //drag your prefab from the project view into here

  //put the rest in start and run once
  MeshFilter GeoMesh = myPrfab.AddComponent<MeshFilter>(); 
  GeoMesh.mesh = local; 
  GeoMesh.sharedMesh = local; Geo.AddComponent<MeshCollider>(); 
  myPrfab.AddComponent<MeshRenderer>(); 
  PrefabUtility.CreatePrefab("Assets/World/myWorld.prefab", Geo);  
  AssetDatabase.SaveAssets();