Cannot using two script to modify the same mesh at the same time

I have one script for modify a mesh’s shape.that script attached in a prefab.the shape will change more depends on the distance between the shape and the prefab.i place one prefab and play,it will fine. But when I place another prefab,only the first one work…?

the code is something like this:

plane=GameObject.Find("default");
m=plane.GetComponent().mesh;
m.MarkDynamic();
va=m.vertices.Clone() as Vector3[];

and then use a for loop to change the vertex’s position “y” which is close to the prefab.
finally:

m.vertices=va;
m.RecalculateNormals();

in the scene,only one prefab can change the mesh as the same time…

EDIT:

i using Debug.Log to trace which vertex has been changed by which Prefab.and the result point out that both Prefab read the same mesh vertex array and success modify them.however,i guess this line:

m.vertices=va;

only one prefab success to apply the changed vertex back to the plane’mesh.

Now two prefab name is “Cube1” and “Cube2”,if i add this in the script:

if(gameObject.name=="Cube1"){
 m.vertices=va;
 m.RecalculateNormals();
 }

only Cube1 will work, if the name change to “Cube2”,only Cube2 work. but remove the “if statement”,can’t see both work…

Use .mesh instead of .sharedMesh so each object gets its own copy.