Hi All !
So I’ve been looking around for a while now and I haven’t managed to find an answer that works to what I’d like to achieve.
I’m looking for a way to find all gameobjects with a tag with GameObject.FindGameObjectWithTag and then disable all of the direct children under that parent, without disabling the parent.
Something like this ?
var fires : GameObject[] = GameObject.FindGameObjectsWithTag("fire");
for(var aFire : GameObject in fires)
{
aFire.active = false;
}
Thanks !
A
Hi,
try something like that, sry but its C#:
GameObject[] fires = GameObject.FindGameObjectsWithTag("fire");
for(int i=0; i<fires.Length; i++)
{
for(int j=0; j<fires*.transform.childCount; j++)*
- {*
_ fires*.transform.GetChild(j).gameObject.active = false;_
_ }_
_}*_
But keep in mind that this is not very performant. E.g. you shouldn’t use it in the Update() method.