How can I speed up assigning a mesh to a MeshCollider?

I am generating large meshes, getting close to Unity’s ~65535 vertex limit. This doesn’t take a long time - in fact, I can modify them in realtime.

However, when I call:

meshCollider.mesh = generatedMesh;

suddenly the whole program freezes for several seconds while this gets done.

Now, I’m assuming there’s a lot of optimisation going on, like assigning vertices to an octree, and so on, but I’m wondering if there’s any way to speed this up at all.

Alternatively, running the process in the background might work, since I don’t need the collision geometry immediately after generating the mesh, but I’m not sure if this is possible in Unity.

Also, settings for the MeshCollider are:

Is Trigger: false
Material: none
Convex: false
Smooth Sphere Collisions: true

It can’t be convex, because it’s a hollow shape, and smooth sphere collisions are on because it needs to be as smooth as possible, since it’s a driving surface.

When generating meshes at runtime, it’s most often the part where the mesh gets assigned to the collider that is taking the longest time. There are no simple workarounds, it’s just that way and not a bug. Consider smaller chunks and spreading their generation out over several frames to help speed thigns up.

I faced such problem when worked over mazes. Walls was too much and they should be connected in one mesh. Then to use the MeshCollider component for this mesh. Time of generation of mesh isn’t enough, but here creation of a collider took some seconds. The acceptable decision for abbreviation of time to find it didn’t turn out. It was necessary to do a certain pause with a text about loading that not bad looked. However, in case of the test on the mobile device (Sony Experia Tablet Z) about 7 mesh with quantity of peaks ~ 65k loading about 10 seconds. Therefore if you have not any random generated mesh, it is best of all to use composite colliders (for example, some BoxCollider).