public GameObject DuplicateObject(GameObject gobject) { // Instantiate with the current transfrom GameObject copy = InstantiateUnityPrefab(gobject); copy.transform.SetParent(gobject.transform.parent, false); // Then put it to righthanded copy.transform.SetParent(SceneManager.RightHanded, true); // Be sure to keep original mesh name MeshFilter[] sourceMeshFilters = gobject.GetComponentsInChildren <MeshFilter>(); if (sourceMeshFilters.Length > 0) { MeshFilter[] copyMeshFilters = copy.GetComponentsInChildren <MeshFilter>(); for (int i = 0; i < sourceMeshFilters.Length; ++i) { copyMeshFilters[i].mesh.name = sourceMeshFilters[i].mesh.name; } } GlobalState.FireObjectAdded(copy); GlobalState.Animation.CopyAnimation(gobject, copy); return(copy); }
public void RestoreObject(GameObject gobject, Transform parent) { gobject.transform.SetParent(parent, true); GlobalState.FireObjectAdded(gobject); }
public GameObject AddObject(GameObject gobject) { gobject.transform.SetParent(SceneManager.RightHanded, false); GlobalState.FireObjectAdded(gobject); return(gobject); }