Skip to content

Commit 0c646d4

Browse files
author
AJubrey
committed
[ADDED] a try-finally statement so that we can guarantee the deletion of the empty game object
1 parent b7610e8 commit 0c646d4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -991,14 +991,21 @@ public HashSet<GameObject> ImplementUpdates(FbxPrefab prefabInstance)
991991
prefabComponents.RemoveAt(index);
992992

993993
GameObject tempGameObject = new GameObject();
994-
Transform tempTransform = tempGameObject.transform;
994+
try
995+
{
996+
997+
Transform tempTransform = tempGameObject.transform;
995998

996-
UnityEditor.EditorJsonUtility.FromJsonOverwrite(fbxComponent.jsonValue, tempTransform);
999+
UnityEditor.EditorJsonUtility.FromJsonOverwrite(fbxComponent.jsonValue, tempTransform);
9971000

998-
prefabComponent.gameObject.GetComponent<RectTransform>().rotation = tempTransform.rotation;
999-
prefabComponent.gameObject.GetComponent<RectTransform>().position = tempTransform.position;
1000-
prefabComponent.gameObject.GetComponent<RectTransform>().localScale = tempTransform.localScale;
1001-
GameObject.DestroyImmediate(tempGameObject);
1001+
prefabComponent.gameObject.GetComponent<RectTransform>().rotation = tempTransform.rotation;
1002+
prefabComponent.gameObject.GetComponent<RectTransform>().position = tempTransform.position;
1003+
prefabComponent.gameObject.GetComponent<RectTransform>().localScale = tempTransform.localScale;
1004+
}
1005+
finally
1006+
{
1007+
GameObject.DestroyImmediate(tempGameObject);
1008+
}
10021009

10031010
Log("updated component {0}:{1}", nodeName, typeof(RectTransform));
10041011
continue;

0 commit comments

Comments
 (0)