Best way to assign mesh verts

I need to generate a procedural mesh with an unknown number of verts. So far, what I’m doing is this:

Vector3[] vertices=new Vector3[LargeNumber];
int vertCount=0;
loopsAndFunctions{
    ...
    vertices[vertCount++]=newVert;
    ...
}
Vector3[] newVertices=new Vector3[vertCount];
for(int i=0;i<vertCount;i++){
    newVertices_=vertices*;*_

}
mesh.vertices=newVertices;
which is ugly. What is the standard method for doing this? I was told that assigning to mesh.vertices* is slow; is that true?*

In C# accessing mesh.vertices won’t even work since mesh.vertices is a property so this line will actually call the get method which returns a copy of the array and you change a member of that copy which you discard at the same time :wink:
If you create this large array only once in Start() it’s not that bad, of course it’s quite ugly :wink:
You can use a List instead:
List vertices = new List();
while(…)
{
vertices.Add(newVert);
}
mesh.vertices = vertices.ToArray();