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