hmmm....
Not quite sure why this is throwing a NullReferenceException
var mesh : Mesh = GetComponent(MeshFilter).mesh;
var vertices : Vector3[] = mesh.vertices;
var normals : Vector3[] = mesh.normals;
var newVertices : Vector3[];
for(var i=0;i<vertices.Length;i++)
{
newVertices _= vertices*;*_
_*}*_
_*```*_
hmmm... ok, I think I'm getting it. But, how would one create a new mesh by getting every-other vertex from the first mesh? It would seem I'd have to cut vertices in half to get the right size, but I wouldn't be able to get every-other vertex, only the first half of the vertices. This is more specific than the question I asked.
– rule62I don't really understand what you wanna do.
– Bunny83mesh.verticesreturns already a copy of the vertex data. All changes made to the array data will not affact the mesh itself. You have to assign the array back tomesh.verticesto "apply" your changes. If you just want to copy all vertices in another array you have to create the new array with the same size of your source array before you can access an element.var newVertices : Vector3[] = new Vertex[vertices.Length];ah, ok. Thank you both.
– rule62Oops, wait. Bunny63, what is "new Vertex[]"? I think that's my confusion.
– rule62That creates a new array. If you don't create the array you can't access the elements. An builtin array have to have a fix size that can't be changed. The size of the array have to be given in the square brackets when you create an array. And sorry i just made a little mistake ;) it should be
– Bunny83= new Vector3[vertices.Length];of course.