Example #1
0
 void Do()
 {
     for (int i = 0; i < replace.Length; i++)
     {
         Transform trs   = replace[i];
         Transform clone = PrefabUtilityExtensions.ClonePrefabInstance(prefab.gameObject).GetComponent <Transform>();
         clone.position = trs.position;
         clone.rotation = trs.rotation;
         clone.SetParent(trs.parent);
         clone.localScale = trs.localScale;
         if (copyMesh)
         {
             MeshFilter meshFilter = trs.GetComponent <MeshFilter>();
             if (meshFilter != null)
             {
                 MeshFilter cloneMeshFilter = clone.GetComponent <MeshFilter>();
                 if (cloneMeshFilter != null)
                 {
                     cloneMeshFilter.mesh = meshFilter.mesh;
                 }
             }
         }
         DestroyImmediate(trs.gameObject);
     }
 }