Adding a prefab or model to an empty game object

So, I am trying to figure out the best way to add something to a game object via script.

I have imported a model and also copied it to an empty prefab and I am trying to figure out how to attach it to an empty gameobject through a script.

I have tried using the gameobject Find and then using AddComponent, but apparently that doesn’t accept objects lol. So, if anyone has a link that better explains to me how to do this, or the line of code that does it, it would be much appreciated.

This is what I last tried. Sloppy, but this is my “get to really know unity” project:

var head1 : GameObject;
head1 = GameObject.Find("head1");
head1.AddComponent(Resources.Load("bodyParts/head1"));

head1 is the empty gameobject attached to my model in the scene.

I tried something similar, but didn’t find anything that would be useful. I tried to switch between an active and inactive character and switch between the components, I didn’t manage to effectively switch between components though.

The way I worked around is that I made 2 versions of the prefab with the needed components and swap them using Instantiate

Hope it helps

The problem with that is I am trying to do this to allow the player to create thier character, so there are too many configurations to make prefabs to load between.

no idea what I’m talking about but perhaps you can just parent all the objects to the empty GO ?