How to insert an instantiated prefab into an object ?

Hello,

How can I attach an instantiated prefab to an object on the scene ?

I use this code, but the method AddComponent doesn’t work :

GameObject child;
child = (GameObject)Instantiate(prefabModels[objectIndex], transform.position, transform.rotation);
child.name = "child"; 
			
GameObject container = GameObject.Find("container");
container.AddComponent("child") as GameObject; //doesn't work

child.transform.parent = container.transform;

Thanks, it works :slight_smile: