- Home /
GetComponentsInChildren(MeshFilter) not recognizing sharedMesh as variable
Hi guys,
I am trying to use the example code from the documentation to add a mesh to an Empty parent, the new mesh being the combination of the Empty's children's meshes. However, I keep getting the error message "BCE0019: 'sharedMesh' is not a member of 'UnityEngine.Component'."
Seems like it will not recognize "sharedMesh" as a variable tied to meshFilter?
Can anyone help me with that?
Thanks!
Answer by Eric5h5 · Jun 24, 2012 at 11:01 PM
The example in the docs unfortunately relies on dynamic typing. While GetComponent automatically casts to the actual component specified (rather than Component), GetComponents does not, unless you use the generic version.
var meshFilters = GetComponentsInChildren.<MeshFilter>();
Thanks Eric5h5! It did get me past the "shared$$anonymous$$esh" problem!
Ran into some other trouble but I am not smart enough (yet) to formulate the problem :-) I don't expect you to sort this is out for me as well but just FYI I get a runtime error saying:
"count <= std::numeric_limits::max() UnityEngine.$$anonymous$$esh:Combine$$anonymous$$eshes(CombineInstance[]) $$anonymous$$eshFromChildren:Start() (at Assets/$$anonymous$$eshFromChildren.js:18)"
I will post another question if I cant figure it out. Thanks again!
This would probably be best with line 18 from $$anonymous$$eshFromChildren.js
included.
Answer by WesternRider · Jun 29, 2012 at 02:12 AM
The above mentioned error was due to the number of vertices in the combined mesh becoming larger than 65,536. With simpler objects the script works just fine.
Your answer
![](https://koobas.hobune.stream/wayback/20220613073223im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Merging meshes 0 Answers
Gather all the Meshes into 1 1 Answer
Mesh.CombineMeshes - what happens to colliders? 0 Answers
Mesh.CombineMeshes - only "main" meshes are combined 0 Answers
CombineMeshes result invisible. 0 Answers