Optimized vertex manipulation

I need to change position of few vertices in my mesh and I need to do it often. However when I try to change vertices position like this:

_objectMeshFilter = GetComponent<MeshFilter>().mesh;
 _objectMeshFilter.vertices *= new Vector3(50 + rand.Next()%5, 50 + rand.Next()%5, 50);*

It does nothing. The value _objectMeshFilter.vertices is not changed, it keeps it’s old value.
I observed approach of creating some kind of own buffer Vector3 array and then assigning it to mesh vertices array. And yes, that works.
var mesh : Mesh = GetComponent(MeshFilter).mesh;
var vertices = new Vector3[baseHeight.Length];
// now modify vertices array
mesh.vertices = vertices // copy whole array ?? NOOOOOooooo, sloooow !! :frowning:
However that is too slow for me. I only need to change few vertices and triangles. Isn’t there any other way to do this than assigning modified Vector3 array to mesh.vertices ? Also I need to do the same thing with triangles. Just edit a little bit.
Every advice appreciated, thanks in advance.

it’s fully explained with excellent full examples, right on the doco page

just copy and paste the example relevant to you! you’re not “re-writing” the mesh.

hope it helps.

This may be useful to you …

click through to the many questions linked

be sure to pls vote up useful answers! :slight_smile: hope it helps