Why Cant I Control a Instantiated Object???

Why can I not control “object01” in “ScriptB”? I even tried controlling it in “ScriptA” and still nothing. I have something like this in a pool manager and works fine. But when I try to do this without using a List, it dose not work. Just wondering why?

ScriptA

  public static ScriptA data;

  public GameObject object01;
     
 void Start()
 {
	data = this;

             Instantiate(object01);
             object01.SetActive (false);
 }

ScripB

void MethodCall ()
{
 	if(!ScriptA.data.object01.activeSelf)
         	{
             		ScriptA.data.object01.transform.position = transform.position;
             		ScriptA.data.object01.SetActive(true);
         	}
}

Try adding:

ScriptA oScript = GetComponant<ScriptA>();

Then you should be able to call the if statement like this:

if(!oScript.data.object01.activeSelf)
{
    ...
}

Basically just change where you have “ScriptA” references in ScriptB to “oScript”.

Never Mind I figured it out:

ScriptA

public GameObject objectA;
public GameObject objectAClone;

objectAClone= Instantiate (objectA) as GameObject;
objectAClone.SetActive (false);

Now I can control the instantiated prefab with “objectAClone”

I think i was referencing the prefab before and not the instantiated object.

Just going to leave this up for others.