Create Vertices on gameObject

I’ve created a plane in Blender with the exact dimensions I need and imported it to Unity.
Now, I need to, dynamically / programmatically, create new vertices on the gameobject. The number of vertices are dynamic, and are sent by another application, so I can’t create the gameobject with the exact number of vertices, from the beginning.
How can I create the vertices on a gameobject through scripting?

My thanks in advanced.

I think most of what you need is covered in the “mesh” script reference:

First of all, thank you for your reply, LeftyRighty

I’ve used the examples in the “mesh” script reference, and apparently I’m able to create the new vertices (because I did Unit tests and the vertices were added to the mesh), but visually nothing happens.

Mesh mesh = new Mesh();
mesh = mainObject.GetComponent().mesh;

int i;
int vertCount = mesh.vertexCount;
vertCount += 2;

Vector3 objectVertices ;
Vector3 newVertices=new Vector3[vertCount];
objectVertices = mesh.vertices;
for (i = 0; i < mesh.vertexCount; i++)
{
newVertices = objectVertices*;*
}

newVertices = new Vector3(-200, -200, -200);
i++;
newVertices = new Vector3(-220, -220, -220);

mesh.vertices = newVertices;
After the last line of code, shouldn’t I be doing some type of refresh to mainObject?
When I used
mesh = mainObject.GetComponent().mesh;
to get the object mesh, shouldn’t I be doing something to use this mesh with the object?
Or does it have to do with the vertices order to draw triangles,…?
[quote=“LeftyRighty, post:2, topic: 526585, username:LeftyRighty”]
I think most of what you need is covered in the “mesh” script reference:
*http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html*_
*[/quote]
*_

After adding new vertex locations, you need to tell the mesh about any new triangles (and probably remove old triangles).
Keep reading the Mesh docs.

This is my personal favorite mesh tutorial:

Procedural Mesh