Find an object after its instantiated.


I have a prefab that I instantiate after hitting a button. I have a script attached to that prefab named NameSpace (terrible naming).

This is the code that I use but it still gives me a null reference :frowning: is this not the way to find an object thats not yet in the scene ?

public class BarManager : MonoBehaviour {

public GameObject prefabToInstantiate;
private NameSpace nameSpaceScript;

public void ThisFunctionTest(){ // this is the function thats runs after hitting the button

	GameObject go = Instantiate(prefabToInstantiate) as GameObject; 

	GameObject space;
	space = GameObject.Find ("Contact(Clone)"); // apparently this doesn't work
	nameSpaceScript = space.GetComponent<NameSpace> () as NameSpace;

	nameSpaceScript.PushingNewConcactInfo (); // not relevant 


}// end barmanager classe

The first time it instantiates, the name does not have (clone) following it. Consider giving the prefab a unique tag and search for the tag instead.