Skip to content

Commit 031e8ee

Browse files
authored
Merge branch 'master' into UNI-21177-convert-default-selection-behavior
2 parents 85959b2 + 54c5276 commit 031e8ee

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,19 @@ protected int ExportComponents (GameObject unityGo, FbxScene fbxScene, FbxNode
484484
/// A count of how many GameObjects we are exporting, to have a rough
485485
/// idea of how long creating the scene will take.
486486
/// </summary>
487-
/// <returns>The object count.</returns>
487+
/// <returns>The hierarchy count.</returns>
488488
/// <param name="exportSet">Export set.</param>
489-
public int GetGameObjectCount (HashSet<GameObject> exportSet)
489+
public int GetHierarchyCount (HashSet<GameObject> exportSet)
490490
{
491491
int count = 0;
492-
foreach (var obj in exportSet) {
493-
count += obj.transform.hierarchyCount;
492+
Queue<GameObject> queue = new Queue<GameObject> (exportSet);
493+
while (queue.Count > 0) {
494+
var obj = queue.Dequeue ();
495+
var objTransform = obj.transform;
496+
foreach (Transform child in objTransform) {
497+
queue.Enqueue (child.gameObject);
498+
}
499+
count++;
494500
}
495501
return count;
496502
}
@@ -502,7 +508,7 @@ public int GetGameObjectCount (HashSet<GameObject> exportSet)
502508
/// </summary>
503509
/// <returns>The revised export set</returns>
504510
/// <param name="unityExportSet">Unity export set.</param>
505-
public static HashSet<GameObject> RemoveDuplicateObjects(IEnumerable<UnityEngine.Object> unityExportSet)
511+
protected HashSet<GameObject> RemoveRedundantObjects(IEnumerable<UnityEngine.Object> unityExportSet)
506512
{
507513
// basically just remove the descendents from the unity export set
508514
HashSet<GameObject> toExport = new HashSet<GameObject> ();
@@ -595,8 +601,8 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
595601
// export set of object
596602
FbxNode fbxRootNode = fbxScene.GetRootNode ();
597603
int i = 0;
598-
var revisedExportSet = RemoveDuplicateObjects(unityExportSet);
599-
int count = GetGameObjectCount (revisedExportSet);
604+
var revisedExportSet = RemoveRedundantObjects(unityExportSet);
605+
int count = GetHierarchyCount (revisedExportSet);
600606
foreach (var unityGo in revisedExportSet) {
601607
i = this.ExportComponents (unityGo, fbxScene, fbxRootNode, i, count);
602608
if (i < 0) {

0 commit comments

Comments
 (0)