Why does the Unity Editor display full mesh after I've programmatically removed vertices?

First - the situation: In an editor script I am performing a preprocessing step on a mesh in a scene to remove polygons that will never be rendered. To do this I:

  • Figure out what triangles will possibly be visible within a mesh.
  • Make a new mesh and assign it to the sharedMesh on the object I'm examining.
  • Fill out a new set of vertices, normals etc that contain only the visible vertices.
  • Fill out all submesh sets of triangles that are in the visible subset on the new mesh.

While both the editor and game now only render the polygons I've left around, selecting the modified gameobject then shows the original mesh (highlighted in green as normal) rather than the reduced one. If I examine the mesh in the asset window, it does correctly show the reduced mesh, and it has the correct vertext count and so on.

My question then is, why is Unity still displaying the original mesh when I select the relevant Game Object? Is there some link to the original asset from which the mesh came which I can't see? If that is the case, to truly create a reduced mesh, would I need to actually save out a new asset and create a totally new mesh based on that?

My guess is that you use a Meshcollider (the green lines are colliders). The Meshcollider component have also a link to a Mesh that should be used for collision detection. I'm sure if you set the Mesh variable of your Meshcollider to your new Mesh it should work. ps. Don't forget to call RecalculateBounds() and evt. RecalculateNormals() after changing the geometry.