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!

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>();

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.