Make a Gameobject active on a clone in a list

Hello everyone,

I have a script which Instantiated Gamobjects(A) constantly on the screen from top to bottom. These Gameobjects(A) contain other Gameobjects(B) which SetActive is set to false by default.
I have a button with a script when clicked the gameobjects(B) should become active but this only works for new Instantiated gameobjects(A). The old gameobjects(A) still have thier gameobjects(B) SetActive set to false.

How can i fix this?
All the Gameobjects(A) are also saved into a list.

So assuming your list of GameObjects(A) is called myObjects and GameObject(B) is their first child.

foreach(GameObject obj in myObjects)
{
    obj.transform.GetChild(0).gameObject.SetActive(true);
}

This code will make the first child of every game object in the list myObjects active. Hope this helps and let me know if it worked. :slight_smile:

1 Like

it works and its so simple…
Thank you so much!