@@ -484,13 +484,19 @@ protected int ExportComponents (GameObject unityGo, FbxScene fbxScene, FbxNode
484
484
/// A count of how many GameObjects we are exporting, to have a rough
485
485
/// idea of how long creating the scene will take.
486
486
/// </summary>
487
- /// <returns>The object count.</returns>
487
+ /// <returns>The hierarchy count.</returns>
488
488
/// <param name="exportSet">Export set.</param>
489
- public int GetGameObjectCount ( HashSet < GameObject > exportSet )
489
+ public int GetHierarchyCount ( HashSet < GameObject > exportSet )
490
490
{
491
491
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 ++ ;
494
500
}
495
501
return count ;
496
502
}
@@ -502,7 +508,7 @@ public int GetGameObjectCount (HashSet<GameObject> exportSet)
502
508
/// </summary>
503
509
/// <returns>The revised export set</returns>
504
510
/// <param name="unityExportSet">Unity export set.</param>
505
- protected HashSet < GameObject > RemoveDuplicateObjects ( IEnumerable < UnityEngine . Object > unityExportSet )
511
+ protected HashSet < GameObject > RemoveRedundantObjects ( IEnumerable < UnityEngine . Object > unityExportSet )
506
512
{
507
513
// basically just remove the descendents from the unity export set
508
514
HashSet < GameObject > toExport = new HashSet < GameObject > ( ) ;
@@ -595,8 +601,8 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
595
601
// export set of object
596
602
FbxNode fbxRootNode = fbxScene . GetRootNode ( ) ;
597
603
int i = 0 ;
598
- var revisedExportSet = RemoveDuplicateObjects ( unityExportSet ) ;
599
- int count = GetGameObjectCount ( revisedExportSet ) ;
604
+ var revisedExportSet = RemoveRedundantObjects ( unityExportSet ) ;
605
+ int count = GetHierarchyCount ( revisedExportSet ) ;
600
606
foreach ( var unityGo in revisedExportSet ) {
601
607
i = this . ExportComponents ( unityGo , fbxScene , fbxRootNode , i , count ) ;
602
608
if ( i < 0 ) {
0 commit comments