How do I set the texture on a child object of an instantiated prefab object?

How do I set the texture on a child object of an instantiated prefab object? I can’t seem to find a way to access the child object’s components, and the only suggestion I’ve found on here is to access the child object as a Transform, which I then don’t appear to be able to GetComponents from.

If I get the object in question, then calling “…transform.GetChild(0);” gets the child object, but returns a Transform rather than a GameObject. I don’t understand why… a Transform apparently only deals with the position, rotation and location of the GameObject. I need to set the texture on this “Transform”…
Any help welcome!



In this case you just need to specify that you want the GameObject from the Transform it would be like


This will get you the child gameObject

then you just have to set the texture

card.transform.GetChild(0).gameObject.GetComponent().mainTexture = “Texture Goes Here”;


GameObject MyGameObject =card.transform.GetChild(0).gameObject;

MyGameObject.GetComponent().mainTexture= “Texture Goes Here”;

On your instantiated clone, get the transform of the child, then get the renderer of that child transform.

// Create a prefab, and get the nail child of the clone
var clone = Instantiate(prefab);
var nail = clone.transform.Find("Left Arm/Hand/Pinky/Nail");
// Ok, not sure why I picked a stupid example, 
// but get the renderer on that nail and change its
// renderers materials texture to fancyPolish.

var nailRenderer = nail.GetComponent<Renderer>();
nailRenderer.material.mainTexture = fancyPolish;

// (It's stupid, because it's stupid to have a renderer 
// on each nail, btw, imo. But that doesn't affect the 
// example otherwise)

If it fails, either you have a typo in your child name, path, or it doesn’t have a renderer.