How to Set GameObject.FindGameObjectsWithTag to SetActive(false)?

Hey guys,

I’ve been searching around and haven’t found anything. Any help is really appreciated.
What is the correct syntax for hiding a gameObject with a tag? I know about gameObject.SetActive (false); but do not know how to do it with a tag.

Here’s what I have:

GameObject.FindGameObjectsWithTag("myTag");

I don’t know where or how to set that SetActive(false);

Any help or links is greatly appreciated.

Thanks!

This should work:

var gos : GameObject[];
//get all the objects with the tag "myTag"
gos = GameObject.FindGameObjectsWithTag("myTag");

//loop through the returned array of game objects and set each to active false
for (var go : GameObject in gos)  {
  go.SetActive(false);
}

GameObject.FindGameObjectWithTag(“myTag”).SetActive(false);