Activate / desactivate using GameObject.FindWithTag

Hi,

I would have a question about GameObject.FindWithTag, i actually have a Gaze script, and on gaze out, i want to input a smallest as possible script to activate or desactivate an object with a spécial tag

the script :

void OnGazeEnd ()
		{
			base.OnGazeEnd ();

			GameObject[] tv = GameObject.FindGameObjectsWithTag("TV1");
			for (int i = 0; i < tv.Length; i++)
			tv*.GetComponent<Renderer>().enabled = false;*
  •  	SetNormalTexture ();*
    
  •  }*
    

I tried with this GameObject[] without any success!
But some simple things like :
Destroy (GameObject.FindWithTag(“TV1”));
works perfectly! badly i dont want to destroy it :wink:
Is anyone have an idea? so i can enable or disable any object whenever this script is used.
Thank you very much

Inside your for loop, put

tv*.SetActive(false);*

or
tv*.SetActive(true);*
depending on what you want to do.

Let me try this.

By the way can I use SetActive(true) when the object is not active from the beginning? inactive in Unity when building