Edit textmesh of prefab child object after instantiate of parent during a loop C#.

Hi Guys - no idea what i’m doing… please help.

I’m failing to edit textmesh of prefab child object after instantiate of parent during a loop.

project setup—>
Prefab Parent Object name = GCube
Prefab Child Object = GCubeText (relationship formed by dragging together in Hierarchy then dragging to project)

project code (component of empty game object) —>

 //starting loop
for (int i = 0; i < pr.Rows.Count; i++){  
Instantiate(prefab, spawnlocation*, Quaternion.identity);*

//renaming prefab object to row number
prefab.name = i.ToString();
//edit childcomponent textmesh
var prefabchildtext = GameObject.Find(“GCubeText”).GetComponent(typeof(TextMesh)) as TextMesh;
prefabchildtext.text = “please help me”;
any of that make sense:)
Currently everything spawns correctly (if I remove the textmesh edit lines), names of prefabs change correct (accept can’t get rid of the clone), but the 3dtext attached to the cubes all still say the default “hello world”.
with these textmesh edit lines i only get one cube instead of the full loop…
Cheers

I don’t see where you have access to your instantiated prefabs

for (int i = 0; i < pr.Rows.Count; i++){ }

prefab.name = i.ToString(); → This give something like
“0”,“1”,“2”,“3”… prefab names in scene

but after that you try access to prefab this maner:

var prefabchildtext = GameObject.Find(“GCubeText”).GetComponent(typeof(TextMesh)) as TextMesh;

But in fact your instantiated prefabs name != “GCubeText”

but the 3dtext attached to the cubes all still say the default "hello world

right, your GameObject.Find dont find GCubeText in the scene
you must search for “0”,“1”,“2”…