Skip to content

Commit 472db1f

Browse files
committed
ignore null components when converting to prefab
1 parent aab851b commit 472db1f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ public static void CopyComponents(GameObject to, GameObject from){
337337
var originalComponents = new List<Component>(to.GetComponents<Component> ());
338338
// copy over meshes, materials, and nothing else
339339
foreach (var component in from.GetComponents<Component>()) {
340+
if (component == null) {
341+
continue;
342+
}
343+
340344
var json = EditorJsonUtility.ToJson(component);
341345
if (string.IsNullOrEmpty (json)) {
342346
// this happens for missing scripts
@@ -348,6 +352,10 @@ public static void CopyComponents(GameObject to, GameObject from){
348352

349353
// Find the component to copy to.
350354
for (int i = 0, n = originalComponents.Count; i < n; i++) {
355+
if (originalComponents [i] == null) {
356+
continue;
357+
}
358+
351359
if (originalComponents[i].GetType() == expectedType) {
352360
// We have found the component we are looking for,
353361
// remove it so we don't try to copy to it again

0 commit comments

Comments
 (0)