@@ -287,30 +287,31 @@ private static void CopyComponents(GameObject from, GameObject to){
287
287
if ( success ) {
288
288
// if to already has this component, then copy the values over
289
289
var toComponent = to . GetComponent ( components [ i ] . GetType ( ) ) ;
290
- if ( toComponent != null ) {
290
+ if ( toComponent == null ) {
291
+ success = UnityEditorInternal . ComponentUtility . PasteComponentAsNew ( to ) ;
292
+ } else {
291
293
// Don't want to copy MeshFilter because then we will replace the
292
294
// exported mesh with the old mesh.
295
+ if ( toComponent is MeshFilter ) {
296
+ continue ;
297
+ }
293
298
// Don't want to copy materials over either in case the materials are
294
299
// embedded in another model.
295
- if ( ! ( toComponent is MeshFilter ) ) {
296
- if ( toComponent is SkinnedMeshRenderer ) {
297
- var skinnedMesh = toComponent as SkinnedMeshRenderer ;
298
- var sharedMesh = skinnedMesh . sharedMesh ;
299
- var sharedMats = skinnedMesh . sharedMaterials ;
300
- success = UnityEditorInternal . ComponentUtility . PasteComponentValues ( toComponent ) ;
301
- skinnedMesh . sharedMesh = sharedMesh ;
302
- skinnedMesh . sharedMaterials = sharedMats ;
303
- } else if ( toComponent is Renderer ) {
304
- var renderer = toComponent as Renderer ;
305
- var sharedMats = renderer . sharedMaterials ;
306
- success = UnityEditorInternal . ComponentUtility . PasteComponentValues ( toComponent ) ;
307
- renderer . sharedMaterials = sharedMats ;
308
- } else {
309
- success = UnityEditorInternal . ComponentUtility . PasteComponentValues ( toComponent ) ;
310
- }
300
+ else if ( toComponent is SkinnedMeshRenderer ) {
301
+ var skinnedMesh = toComponent as SkinnedMeshRenderer ;
302
+ var sharedMesh = skinnedMesh . sharedMesh ;
303
+ var sharedMats = skinnedMesh . sharedMaterials ;
304
+ success = UnityEditorInternal . ComponentUtility . PasteComponentValues ( toComponent ) ;
305
+ skinnedMesh . sharedMesh = sharedMesh ;
306
+ skinnedMesh . sharedMaterials = sharedMats ;
307
+ } else if ( toComponent is Renderer ) {
308
+ var renderer = toComponent as Renderer ;
309
+ var sharedMats = renderer . sharedMaterials ;
310
+ success = UnityEditorInternal . ComponentUtility . PasteComponentValues ( toComponent ) ;
311
+ renderer . sharedMaterials = sharedMats ;
312
+ } else {
313
+ success = UnityEditorInternal . ComponentUtility . PasteComponentValues ( toComponent ) ;
311
314
}
312
- } else {
313
- success = UnityEditorInternal . ComponentUtility . PasteComponentAsNew ( to ) ;
314
315
}
315
316
}
316
317
if ( ! success ) {
0 commit comments