@@ -86,21 +86,6 @@ public static GameObject[] CreateInstantiatedModelPrefab (
86
86
var wasExported = new List < GameObject > ( ) ;
87
87
foreach ( var go in toExport ) {
88
88
try {
89
- if ( go . transform . parent == null ) {
90
- PrefabType unityPrefabType = PrefabUtility . GetPrefabType ( go ) ;
91
- if ( unityPrefabType == PrefabType . ModelPrefabInstance ) {
92
- // don't re-export fbx
93
- // create prefab out of model instance in scene, link to existing fbx
94
- var mainAsset = PrefabUtility . GetPrefabParent ( go ) as GameObject ;
95
- var mainAssetRelPath = AssetDatabase . GetAssetPath ( mainAsset ) ;
96
- var mainAssetAbsPath = Directory . GetParent ( Application . dataPath ) + "/" + mainAssetRelPath ;
97
- SetupFbxPrefab ( go , mainAsset , mainAssetRelPath , mainAssetAbsPath ) ;
98
-
99
- wasExported . Add ( go ) ;
100
- continue ;
101
- }
102
- }
103
-
104
89
wasExported . Add ( Convert ( go ,
105
90
directoryFullPath : directoryFullPath ) ) ;
106
91
} catch ( System . Exception xcp ) {
@@ -132,6 +117,20 @@ public static GameObject Convert (
132
117
string directoryFullPath = null ,
133
118
string fbxFullPath = null )
134
119
{
120
+ if ( toConvert . transform . parent == null ) {
121
+ PrefabType unityPrefabType = PrefabUtility . GetPrefabType ( toConvert ) ;
122
+ if ( unityPrefabType == PrefabType . ModelPrefabInstance ) {
123
+ // don't re-export fbx
124
+ // create prefab out of model instance in scene, link to existing fbx
125
+ var mainAsset = PrefabUtility . GetPrefabParent ( toConvert ) as GameObject ;
126
+ var mainAssetRelPath = AssetDatabase . GetAssetPath ( mainAsset ) ;
127
+ var mainAssetAbsPath = Directory . GetParent ( Application . dataPath ) + "/" + mainAssetRelPath ;
128
+ SetupFbxPrefab ( toConvert , mainAsset , mainAssetRelPath , mainAssetAbsPath ) ;
129
+
130
+ return toConvert ;
131
+ }
132
+ }
133
+
135
134
if ( string . IsNullOrEmpty ( fbxFullPath ) ) {
136
135
// Generate a unique filename.
137
136
if ( string . IsNullOrEmpty ( directoryFullPath ) ) {
@@ -184,7 +183,7 @@ public static GameObject Convert (
184
183
185
184
186
185
/// <summary>
187
- /// Create the fbx prefab and connect it to the given fbx asset.
186
+ /// Create the prefab and connect it to the given fbx asset.
188
187
/// </summary>
189
188
/// <param name="toConvert">Hierarchy to convert.</param>
190
189
/// <param name="unityMainAsset">Main asset in the FBX.</param>
0 commit comments