Collider sharedmesh crash

Hi, I'm working into a unity's project, and there is a null pointer occuring inside the collider's sharedmesh setter:

Invalid parameter because it was infinity or nan. UnityEngine.MeshCollider:set_sharedMesh(Mesh) UnityEngine.MeshCollider:set_sharedMesh(Mesh) ...

at (wrapper managed-to-native) UnityEngine.MeshCollider.set_sharedMesh (UnityEngine.Mesh) <0x00004> at (wrapper managed-to-native) UnityEngine.MeshCollider.set_sharedMesh ... State.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff> Receiving unhandled NULL exception Trying to recover from null exception ]

and after this, the game freezes. i have checked the mesh, and its valid, have vertexes and indexes ( triangles ), and the collider is not null. Somebody know what can be the problem? it can be a unity bug?


I think this is a bug. I was having a terrible time tracking down a similar (occasional) error when setting a MeshCollider, though mine was an "Object reference not set to an instance of an object". It turned out that previously in the same function I had done a try/catch. The catch had handled an exception caused by a null reference. Apparently something about the error condition was not cleared and Unity's code for setting the sharedMesh of the MeshCollider responded to it.

I suggest you check your code to see if you are trapping an invalid parameter exception. Perhaps you can check the parameters manually and avoid precipitating this bug, if bug it is. That is what worked for me. If there is a way to clear an error condition, I'd love to hear of it.