[1216-GetComponentInChildren.unitypackage.zip|1216]I needed to shift the pivot of a prfab, so I created an empty game object at the position I want my pivot. Then I made the prefab a child of it. Then I turned this new construct into a prefab that I use at runtime to instantiate objects. I need to get the renderer of the actual game object and I’m using this call:
Renderer renderer = wall.GetComponentInChildren< Renderer >();
The child object indeed has an active renderer attached, but the above call always returns null. I also tried changing Renderer to MeshRenderer with no luck. Prior to parenting the prefab, I was able to get the renderer by simply saying:
The parent object has only one component: the transform, and only one child: a wall model. The wall model has four components: Transform, MeshFilter, MeshRenderer, and Collider.
From what I see in the docs, this call should succeed. Any idea what I’m doing wrong? Is there a better, or different way to do this?