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 ?
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 …
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.