Instantiate existing components and assign to GameObject

I want to make a clone of a prefab in code, but only in looks- no logic. I’m attempting to make a very generic class that will do this, but am having trouble copying a component from an existing object to my new object.

I’ve read in Object.Instantiate that one can instantiate components, but I’ve also read in GameObject that ‘You can’t create Component and then make a reference from object to it.’ Now, putting both articles together, it looks like I can indeed instantiate a clone of a GameObject’s component, but I’m unable to actually add it to another GameObject… which makes me wonder just what use this is.

I’ve tried doing this 20 different ways, but so far, nothing has worked. Here is my last failed attempt, although it’s possible I’ve modified it so much it’s junk now.

Mesh FooMesh = Instantiate(this.gameObject.GetComponent<Mesh>) as Mesh;
foo.AddComponent(FooMesh);

Am I overlooking something obvious here? I don’t really want to modify all my prefabs and write junk code to add back all the various script components each time I instantiate one. Thanks in advance.

You can't instantiate individual components, because they rely heavily on the state of the gameObject to which they are attached. If you want to copy an object's mesh and renderer alone, you should make a prefab that has only a mesh filter and renderer, and then use

clone.GetComponent<MeshFilter>().mesh = GetComponent<MeshFilter>().sharedMesh;

It is also possible to make a complete clone, and then modify or delete the components you either don't need or want changed.

Basically, you can't just copy components, because a component usually has lots and lots of references to the object it is a 'part' of, and so will become nigh inoperable if you were to break those.