Clone an Object

Hy Guys …
Im new to Unity …

How could I clone objects in Unity, by Scripting ?
I have the following:

So what i wanted is that the my HashTable contained a copy of the Mesh contained in the GameObject called “Body”…but instead i just have the reference for the same Mesh, which means that if I change the Mesh at the GameObject the Mesh at the HashTable is also changed !!!

How Could I jus duplicate the Mesh without changing anything at the GameObject ?

Would be there anything similar to:

???

Thanks in Advance !!!

I don’t know if you can use corpomesh.MemberwiseClone() in JavaScript, you could try it, it returns a clone of the object.

I ve Tried this …

But it still didnt work !! :frowning:

Thank you anyway!

Use this to clone the entire game object with his components.

var original:GameObject = GameObject.Find("Body");
var clone:GameObject = Instantiate(original);

Then you can use the new mesh without affecting the original.

Yes it kind of worked, but not as expected…
Because when I call:

var clone1:GameObject = Instantiate(GameObject.Find("cabeca"));
	 var clone2:GameObject = Instantiate(GameObject.Find("Corpo"));

It can clone …but it appears on Screen …and i didnt want that it appeared on Screen , I wanted just to clone it and keep a Clone of it on memory …just like in Java ,… Object.Clone(); …and keep it at the memory …

Would be this possible in Unity ?

Thanks anyway lehk !!!

Forgot that detail, sorry.
It’s a bit tricky but if you want to remove it from the screen, you can disable the render adding the next line:

clone.GetComponent("MeshRenderer").renderer.enabled = false;

Or, you can change the type on your vars declarations to Object instead of GameObject.

I did exacly the same:

Instantiate(body);

and i also tried

Instantiate(GameObject.Find("body"));

But the Clones mesh still seems to be a reference to the original Mesh. Afterwards i am changing the original, but all the Changes are applied to the new GameObjects mesh too. I dont use the clone in any ways, but it should stay in exacly the same state it had on its initialization.
Is there another way, or am i missing some thing?

EDIT Ok, i have a workaround which is useable for my special case. Done.