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 !!
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.