@@ -33,6 +33,8 @@ namespace FbxExporters
33
33
const string MenuItemName = "GameObject/Update from FBX" ;
34
34
public static bool runningUnitTest = false ;
35
35
36
+ public static bool Verbose { private set { ; } get { return EditorTools . ExportSettings . instance . Verbose ; } }
37
+
36
38
public static string FindFbxPrefabAssetPath ( )
37
39
{
38
40
// Find guids that are scripts that look like FbxPrefab.
@@ -90,7 +92,9 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
90
92
return ;
91
93
}
92
94
93
- //Debug.Log("Postprocessing...");
95
+ if ( Verbose ) {
96
+ Debug . Log ( "Postprocessing..." ) ;
97
+ }
94
98
95
99
// Did we import an fbx file at all?
96
100
// Optimize to not allocate in the common case of 'no'
@@ -102,13 +106,19 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
102
106
fbxImported = new HashSet < string > ( ) ;
103
107
}
104
108
fbxImported . Add ( fbxModel ) ;
105
- //Debug.Log("Tracking fbx asset " + fbxModel);
109
+ if ( Verbose ) {
110
+ Debug . Log ( "Tracking fbx asset " + fbxModel ) ;
111
+ }
106
112
} else {
107
- //Debug.Log("Not an fbx asset " + fbxModel);
113
+ if ( Verbose ) {
114
+ Debug . Log ( "Not an fbx asset " + fbxModel ) ;
115
+ }
108
116
}
109
117
}
110
118
if ( fbxImported == null ) {
111
- //Debug.Log("No fbx imported");
119
+ if ( Verbose ) {
120
+ Debug . Log ( "No fbx imported" ) ;
121
+ }
112
122
return ;
113
123
}
114
124
@@ -125,14 +135,20 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
125
135
foreach ( var guid in allObjectGuids ) {
126
136
var prefabPath = AssetDatabase . GUIDToAssetPath ( guid ) ;
127
137
if ( ! IsPrefabAsset ( prefabPath ) ) {
128
- //Debug.Log("Not a prefab: " + prefabPath);
138
+ if ( Verbose ) {
139
+ Debug . Log ( "Not a prefab: " + prefabPath ) ;
140
+ }
129
141
continue ;
130
142
}
131
143
if ( ! MayHaveFbxPrefabToFbxAsset ( prefabPath , fbxPrefabScriptPath , fbxImported ) ) {
132
- //Debug.Log("No dependence: " + prefabPath);
144
+ if ( Verbose ) {
145
+ Debug . Log ( "No dependence: " + prefabPath ) ;
146
+ }
133
147
continue ;
134
148
}
135
- //Debug.Log("Considering updating prefab " + prefabPath);
149
+ if ( Verbose ) {
150
+ Debug . Log ( "Considering updating prefab " + prefabPath ) ;
151
+ }
136
152
137
153
// We're now guaranteed that this is a prefab, and it depends
138
154
// on the FbxPrefab script, and it depends on an Fbx file that
@@ -143,21 +159,29 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
143
159
// update the prefab anyway).
144
160
var prefab = AssetDatabase . LoadMainAssetAtPath ( prefabPath ) as GameObject ;
145
161
if ( ! prefab ) {
146
- //Debug.LogWarning("FbxPrefab reimport: failed to update prefab " + prefabPath);
162
+ if ( Verbose ) {
163
+ Debug . LogWarning ( "FbxPrefab reimport: failed to update prefab " + prefabPath ) ;
164
+ }
147
165
continue ;
148
166
}
149
167
foreach ( var fbxPrefabComponent in prefab . GetComponentsInChildren < FbxPrefab > ( ) ) {
150
168
var fbxPrefabUtility = new FbxPrefabUtility ( fbxPrefabComponent ) ;
151
169
if ( ! fbxPrefabUtility . WantsAutoUpdate ( ) ) {
152
- //Debug.Log("Not auto-updating " + prefabPath);
170
+ if ( Verbose ) {
171
+ Debug . Log ( "Not auto-updating " + prefabPath ) ;
172
+ }
153
173
continue ;
154
174
}
155
175
var fbxAssetPath = fbxPrefabUtility . GetFbxAssetPath ( ) ;
156
176
if ( ! fbxImported . Contains ( fbxAssetPath ) ) {
157
- //Debug.Log("False-positive dependence: " + prefabPath + " via " + fbxAssetPath);
177
+ if ( Verbose ) {
178
+ Debug . Log ( "False-positive dependence: " + prefabPath + " via " + fbxAssetPath ) ;
179
+ }
158
180
continue ;
159
181
}
160
- //Debug.Log("Updating " + prefabPath + "...");
182
+ if ( Verbose ) {
183
+ Debug . Log ( "Updating " + prefabPath + "..." ) ;
184
+ }
161
185
fbxPrefabUtility . SyncPrefab ( ) ;
162
186
}
163
187
}
@@ -347,7 +371,7 @@ public string GetFBXObjectName(string unityObjectName)
347
371
/// </summary>
348
372
[ System . Diagnostics . Conditional ( "FBXEXPORTER_DEBUG" ) ]
349
373
public static void Log ( string message ) {
350
- Debug . Log ( "Fbx prefab update: " + message ) ;
374
+ Debug . Log ( "Fbx prefab update: " + message ) ;
351
375
}
352
376
353
377
[ System . Diagnostics . Conditional ( "FBXEXPORTER_DEBUG" ) ]
@@ -1226,7 +1250,10 @@ public HashSet<GameObject> ImplementUpdates(FbxPrefab prefabInstance)
1226
1250
var componentName = kvp . Key ;
1227
1251
// We rename the node before the loop, so the component name now has the FBX object name, instead of the unity one that was saved
1228
1252
componentName = m_fbxPrefabUtility . GetFBXObjectName ( componentName ) ;
1229
- Debug . Log ( "Component: " + componentName ) ;
1253
+
1254
+ if ( Verbose ) {
1255
+ Debug . Log ( "Component: " + componentName ) ;
1256
+ }
1230
1257
var fbxComponents = kvp . Value ;
1231
1258
var prefabXfo = prefabNodes [ componentName ] ;
1232
1259
updatedNodes . Add ( prefabXfo . gameObject ) ;
0 commit comments