BCE0019: 'vertices' is not a member of 'Object'.

I keep getting "BCE0019: ‘vertices’ is not a member of ‘Object’. " error. Not sure whats not quite right.

	for(i=0; i < objChildren.Count; i++){
	    objMeshList.Add(objChildren*.gameObject.GetComponent(MeshFilter).mesh);*
  • }*

  • for(i=0; i < objMeshList.Count; i++){*
    _ thisObj = objMeshList*;_
    _
    for(theseVectors in thisObj){_
    _
    vertexAll.Add(theseVectors.vertices);_
    _
    normalsAll.Add(theseVectors.normals);_
    _
    }_
    _
    }*_

How did you declare theseVectors? My guess is that you did: var theseVectors; and you need to do: var theseVectors : Mesh; (assuming theseVectors is a mesh).

I actually didn't assign it to anything, its just a holder variable. I tried specifying that it is a mesh, like you said, but no luck.#pragma strict is on, but I have other holder variables in other for() loops and it doesnt care about those not being pre defined. I don't understand why Unity thinks my objMeshList is a list of Objects?

Are you absolutely sure you have '#pragma strict' as the first line in your file? With #pragma strict, this code should be outputting a slew of errors.

yes, this is just the important part of the code, to make reading easier.

1 Answer

1

objMeshList is a

List<mesh>()

, right? (I’m assuming from line 2)

So, if thisObj is an element from this list, it’s a mesh, and meshes don’t have “theseVectors”. So the error is on line 8 - what is “theseVectors”, and is objMeshList meant to be a list of whatever sort of class has it?

Basically, your problem lies in relying upon Javascripts dynamic typecasting - a feature that many people think makes Javascript easier, but in most cases ends up being a royal PITA. Always type all your variables, and problems like this should go away.

Thank you, typecasting it fixed that. I see now thats what robertbu was saying also, thought he meant just having the var defined at the top of the script.