[Solved] Changing mesh of child gameobject

Hello,

I want to change the mesh of a gameobject which is the child of another gameobject. I locate the mesh, copy it, change it, clear the old mesh and replace it, as described in the script reference but the changes don’t seem to take effect.

Is it because it’s a child object? Here’s my code briefly, I feel like it should work:

Transform parentTransform;
Transform childTransform;
Mesh mesh;
Vector3[] vertices;
Vector3 vert;
Vector2[] uv;
int[] triangles;
...
childTransform = parentTransform.Find(childname)
mesh = childTransform.gameObject.GetComponent<MeshFilter>().mesh;
vertices = mesh.vertices;
uv = mesh.uv;
triangles = mesh.triangles;
vert = vertices[0];
vert.y += 5; // Change y of a single vert
vertices[0] = vert;
mesh.Clear(); // Clear old mesh
mesh.vertices = vertices; // Assign new vertices with that one altered point
mesh.uv = uv;
mesh.triangles = triangles;
childTransform.gameObject.GetComponent<MeshFilter>().mesh = mesh; // Not sure if necessary

Well, I found my answer. Adding the solution incase anyone ever runs into the same problem:

I modified the vertices of the child objects, but I was actually displaying the parent mesh, which was a combined mesh made of the child meshes. I then modfied the parent mesh instead and everything worked fine.