- Home /
Other
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[i].gameObject.GetComponent(MeshFilter).mesh);
}
for(i=0; i < objMeshList.Count; i++){
thisObj = objMeshList[i];
for(theseVectors in thisObj){
vertexAll.Add(theseVectors.vertices);
normalsAll.Add(theseVectors.normals);
}
}
How did you declare theseVectors? $$anonymous$$y guess is that you did:
var theseVectors;
and you need to do:
var theseVectors : $$anonymous$$esh;
(assu$$anonymous$$g 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 obj$$anonymous$$eshList 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.
Answer by tanoshimi · Jul 22, 2014 at 06:30 PM
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.