Controlling prefabs from Resources Folder

I have loaded a bunch of prefabs which have objects on the scene. Now I choose to randomly disable one from the script. As the object on the scene is attached to the prefab and the prefab is controlled by the script, I assumed I could setActive (false). This didn’t work. Is there a way to disable the prefab set in the resources such that it reflects on the scene.

public GameObject[] tableObjects;
void Start () 
	{
		tableObjects = Resources.LoadAll<GameObject> ("GameObjects");
                for (int i=0; i<objCount; i++) 
		{
			tableObjects*.SetActive (true);*
  •  }*
    

}

  • void SelectRandomObjects(int GameLevel) {*
  •  for (int i = 1; i <= GameLevel; i++) {*
    
  •  	int x = Random.Range(0,30);*
    
  •  	if (tableObjects[x].activeSelf == false)*
    
  •  		i--;*
    
  •  	else*
    
  •  	{*
    
  •  		tableObjects[x].SetActive (false);* 
    

_ /* This disables the prefab but only when I load the scene again does it appeared disabled */_
}

  •  }*
    
  • }*

@adichav
Perhaps you can Destroy (gameObject); then instantiate the object back when needed unless you’re trying to store info in that object.

Or try to enable/disable the script or component with this line of code.
gameobject.GetComponent< SomeScript >().enabled = true;

Let me know if that helps.