How to find all Cube game Object in the scene ?


I’m looking for a way to find all CubeGameObject in the scene.
I’m trying to do this :

Cube[] ballsUp = FindObjectsOfType (typeof(Cube)) as Cube[];

But cube isn’t a game object type apparently.

I think i need to use something related to PrimitiveType but can figure out what and how to use it…


When I add a Cube GameObject into my scene, and look at it in the Inspector, I can see that it contains a MeshFilter component called Cube. I guess looking for GameObjects that have this MeshFilter is the way to proceed. Note that Cube is not a type.