Instantiating to be an child of an object.

Hey I hope someone can help me with this problem I am having. I want to instantiate a prefab to be a child of another game object. So basically I have two gui buttons, one I want to make a sphere appear as a child of a game object, and then the second button would make a cube spawn as a child of the game object, so you can swap between a cube and sphere on that game object.

Any help would be awesome!

basically i want to replace one prefab with another, but so it is a child of the same empty game object

You can use transform.parent to set the parent of the new object to that of the old:-

var newObj = Instantiate(...);
newObj.transform.parent = oldObj.transform.parent;
Destroy(oldObj);

yeah its all good. I have everything working now, thanks for the reply anyway