Can i reference a deactivated (not public) gameobject?

It’s a child of an object. i set that child’s SetActive to false when i collide with it
Now, when a certain object triggers the parent i want to set that child’s SetActive to true again… i’ve tried GetComponentsInChildren but the problem is that that child’s components wont show in the array because it is not active, also i can’t store the child object in a public transform because it is not the same child that gets set to inactive every time (there’s alot of children to the parent object). Soo is there another way of doing it? Help would be appreciated

Check out the function signature, there is an optional parameter to help you.

There are ways to find inactive objects.

Some options to consider

  • Get a reference to the object when it is set inactive.

  • Get and hold a reference to all children all the time

  • Set active all of the children of the object

  • Iterate ove all children and look for an inactive one

can you make an example of how to use that function with the extra bool?? because there’s no example for it in the link.

just pass “true” as the second parameter, and it will return disabled components too.

Suppose that i want to get all children with type Transform… what should i type to do it? (Example script would be more helpful than ‘do and don’t’ kind of answer)

gameObject.GetComponentsInChildren (true); :slight_smile:

1 Like

thanks! that worked