Skip to content

Commit 7de21e1

Browse files
authored
Merge pull request #315 from Unity-Technologies/UNI-39486-name-remapping-debug-verbose-only
UNI-39486 log name remapping messages only if verbose is on
2 parents c217443 + 1d4a510 commit 7de21e1

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ namespace FbxExporters
3333
const string MenuItemName = "GameObject/Update from FBX";
3434
public static bool runningUnitTest = false;
3535

36+
public static bool Verbose { private set {;} get { return EditorTools.ExportSettings.instance.Verbose; } }
37+
3638
public static string FindFbxPrefabAssetPath()
3739
{
3840
// Find guids that are scripts that look like FbxPrefab.
@@ -90,7 +92,9 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
9092
return;
9193
}
9294

93-
//Debug.Log("Postprocessing...");
95+
if (Verbose) {
96+
Debug.Log ("Postprocessing...");
97+
}
9498

9599
// Did we import an fbx file at all?
96100
// Optimize to not allocate in the common case of 'no'
@@ -102,13 +106,19 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
102106
fbxImported = new HashSet<string>();
103107
}
104108
fbxImported.Add(fbxModel);
105-
//Debug.Log("Tracking fbx asset " + fbxModel);
109+
if (Verbose) {
110+
Debug.Log ("Tracking fbx asset " + fbxModel);
111+
}
106112
} else {
107-
//Debug.Log("Not an fbx asset " + fbxModel);
113+
if (Verbose) {
114+
Debug.Log ("Not an fbx asset " + fbxModel);
115+
}
108116
}
109117
}
110118
if (fbxImported == null) {
111-
//Debug.Log("No fbx imported");
119+
if(Verbose){
120+
Debug.Log("No fbx imported");
121+
}
112122
return;
113123
}
114124

@@ -125,14 +135,20 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
125135
foreach (var guid in allObjectGuids) {
126136
var prefabPath = AssetDatabase.GUIDToAssetPath(guid);
127137
if (!IsPrefabAsset(prefabPath)) {
128-
//Debug.Log("Not a prefab: " + prefabPath);
138+
if (Verbose) {
139+
Debug.Log ("Not a prefab: " + prefabPath);
140+
}
129141
continue;
130142
}
131143
if (!MayHaveFbxPrefabToFbxAsset(prefabPath, fbxPrefabScriptPath, fbxImported)) {
132-
//Debug.Log("No dependence: " + prefabPath);
144+
if(Verbose){
145+
Debug.Log("No dependence: " + prefabPath);
146+
}
133147
continue;
134148
}
135-
//Debug.Log("Considering updating prefab " + prefabPath);
149+
if (Verbose) {
150+
Debug.Log ("Considering updating prefab " + prefabPath);
151+
}
136152

137153
// We're now guaranteed that this is a prefab, and it depends
138154
// on the FbxPrefab script, and it depends on an Fbx file that
@@ -143,21 +159,29 @@ static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[]
143159
// update the prefab anyway).
144160
var prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath) as GameObject;
145161
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+
}
147165
continue;
148166
}
149167
foreach (var fbxPrefabComponent in prefab.GetComponentsInChildren<FbxPrefab>()) {
150168
var fbxPrefabUtility = new FbxPrefabUtility(fbxPrefabComponent);
151169
if (!fbxPrefabUtility.WantsAutoUpdate()) {
152-
//Debug.Log("Not auto-updating " + prefabPath);
170+
if (Verbose) {
171+
Debug.Log ("Not auto-updating " + prefabPath);
172+
}
153173
continue;
154174
}
155175
var fbxAssetPath = fbxPrefabUtility.GetFbxAssetPath();
156176
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+
}
158180
continue;
159181
}
160-
//Debug.Log("Updating " + prefabPath + "...");
182+
if (Verbose) {
183+
Debug.Log ("Updating " + prefabPath + "...");
184+
}
161185
fbxPrefabUtility.SyncPrefab();
162186
}
163187
}
@@ -347,7 +371,7 @@ public string GetFBXObjectName(string unityObjectName)
347371
/// </summary>
348372
[System.Diagnostics.Conditional("FBXEXPORTER_DEBUG")]
349373
public static void Log(string message) {
350-
Debug.Log("Fbx prefab update: " + message);
374+
Debug.Log ("Fbx prefab update: " + message);
351375
}
352376

353377
[System.Diagnostics.Conditional("FBXEXPORTER_DEBUG")]
@@ -1226,7 +1250,10 @@ public HashSet<GameObject> ImplementUpdates(FbxPrefab prefabInstance)
12261250
var componentName = kvp.Key;
12271251
// 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
12281252
componentName = m_fbxPrefabUtility.GetFBXObjectName(componentName);
1229-
Debug.Log("Component: " + componentName);
1253+
1254+
if (Verbose) {
1255+
Debug.Log ("Component: " + componentName);
1256+
}
12301257
var fbxComponents = kvp.Value;
12311258
var prefabXfo = prefabNodes[componentName];
12321259
updatedNodes.Add(prefabXfo.gameObject);

Assets/FbxExporters/Editor/ManualUpdateEditorWindow.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class ManualUpdateEditorWindow : EditorWindow
1818

1919
List<string> m_nodeNameToSuggest;
2020

21+
public bool Verbose { private set {;} get { return FbxExporters.EditorTools.ExportSettings.instance.Verbose; } }
22+
2123
public void Init(FbxPrefabAutoUpdater.FbxPrefabUtility fbxPrefabUtility, FbxPrefab fbxPrefab)
2224
{
2325
FbxPrefabAutoUpdater.FbxPrefabUtility.UpdateList updates = new FbxPrefabAutoUpdater.FbxPrefabUtility.UpdateList(new FbxPrefabAutoUpdater.FbxPrefabUtility.FbxRepresentation(fbxPrefab.FbxHistory), fbxPrefab.FbxModel.transform, fbxPrefab);
@@ -137,7 +139,10 @@ void ApplyChanges()
137139
stringpair.UnityObjectName = m_nodesToDestroy[i];
138140

139141
m_fbxPrefab.NameMapping.Add(stringpair);
140-
Debug.Log("Mapped Unity: " + stringpair.UnityObjectName + " to FBX: " + stringpair.FBXObjectName);
142+
143+
if (Verbose) {
144+
Debug.Log ("Mapped Unity: " + stringpair.UnityObjectName + " to FBX: " + stringpair.FBXObjectName);
145+
}
141146
}
142147
}
143148

@@ -161,11 +166,15 @@ void ApplyChanges()
161166
stringpair.UnityObjectName = currentUnityNodeName;
162167
m_fbxPrefab.NameMapping.Add(stringpair);
163168

164-
Debug.Log("Mapped Unity: " + stringpair.UnityObjectName + " to FBX: " + stringpair.FBXObjectName);
169+
if (Verbose) {
170+
Debug.Log ("Mapped Unity: " + stringpair.UnityObjectName + " to FBX: " + stringpair.FBXObjectName);
171+
}
165172
}
166173
else
167174
{
168-
Debug.Log("ALREADY Mapped Unity: " + currentUnityNodeName + " to FBX: " + options[selectedNodesToRename[i]].text);
175+
if (Verbose) {
176+
Debug.Log ("ALREADY Mapped Unity: " + currentUnityNodeName + " to FBX: " + options [selectedNodesToRename [i]].text);
177+
}
169178
}
170179
}
171180
}

0 commit comments

Comments
 (0)