Skip to content

Commit f63ac63

Browse files
committed
clean up code
1 parent 6879e36 commit f63ac63

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -287,30 +287,31 @@ private static void CopyComponents(GameObject from, GameObject to){
287287
if (success) {
288288
// if to already has this component, then copy the values over
289289
var toComponent = to.GetComponent (components [i].GetType ());
290-
if (toComponent != null) {
290+
if (toComponent == null) {
291+
success = UnityEditorInternal.ComponentUtility.PasteComponentAsNew (to);
292+
} else{
291293
// Don't want to copy MeshFilter because then we will replace the
292294
// exported mesh with the old mesh.
295+
if (toComponent is MeshFilter) {
296+
continue;
297+
}
293298
// Don't want to copy materials over either in case the materials are
294299
// 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);
311314
}
312-
} else {
313-
success = UnityEditorInternal.ComponentUtility.PasteComponentAsNew (to);
314315
}
315316
}
316317
if (!success) {

0 commit comments

Comments
 (0)