Hi, i have boxes gameobject and its children. Before i rotate or move this object, i insantiate all of them with using Record() method and if user want to take back action with using Undo() method, all objects including its clones is destroyed, so i dont want to destroy clone objects. how to break connection between gameobject and its clone. Sorry for my english thanks in advance. Here is the code
public Gameobject boxes, boxesCopy;
public void Record(){
if (boxesCopy != null) {
Destroy (boxesCopy);
}
boxesCopy=Instantiate(boxes);
boxesCopy.SetActive (false);
}
public void Undo(){
Transform[] realChildren = boxes.GetComponentsInChildren<Transform>();
foreach (Transform child in realChildren)
{
Destroy (child.gameObject);
}
Transform[] copyChildren = boxesCopy.GetComponentsInChildren<Transform>();
foreach (Transform child in copyChildren)
{
child.transform.parent = boxes.transform;
child.SetActive (true);
}
}