@@ -465,19 +465,19 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
465
465
/// </summary>
466
466
protected int ExportComponents (
467
467
GameObject unityGo , FbxScene fbxScene , FbxNode fbxNodeParent ,
468
- int currentIndex , int objectCount , TransformExportType exportType = TransformExportType . Local )
468
+ int exportProgress , int objectCount , TransformExportType exportType = TransformExportType . Local )
469
469
{
470
- int i = currentIndex ;
470
+ int numObjectsExported = exportProgress ;
471
471
472
472
// create an FbxNode and add it as a child of parent
473
473
FbxNode fbxNode = FbxNode . Create ( fbxScene , unityGo . name ) ;
474
474
NumNodes ++ ;
475
475
476
- i ++ ;
476
+ numObjectsExported ++ ;
477
477
if ( EditorUtility . DisplayCancelableProgressBar (
478
478
ProgressBarTitle ,
479
- string . Format ( "Creating FbxNode {0}/{1}" , i , objectCount ) ,
480
- ( i / ( float ) objectCount ) * 0.5f ) ) {
479
+ string . Format ( "Creating FbxNode {0}/{1}" , numObjectsExported , objectCount ) ,
480
+ ( numObjectsExported / ( float ) objectCount ) * 0.5f ) ) {
481
481
// cancel silently
482
482
return - 1 ;
483
483
}
@@ -494,9 +494,9 @@ protected int ExportComponents (
494
494
495
495
// now unityGo through our children and recurse
496
496
foreach ( Transform childT in unityGo . transform ) {
497
- i = ExportComponents ( childT . gameObject , fbxScene , fbxNode , i , objectCount ) ;
497
+ numObjectsExported = ExportComponents ( childT . gameObject , fbxScene , fbxNode , numObjectsExported , objectCount ) ;
498
498
}
499
- return i ;
499
+ return numObjectsExported ;
500
500
}
501
501
502
502
/// <summary>
@@ -621,24 +621,25 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
621
621
622
622
// export set of object
623
623
FbxNode fbxRootNode = fbxScene . GetRootNode ( ) ;
624
- int i = 0 ;
624
+ // stores how many objects we have exported, -1 if export was cancelled
625
+ int exportProgress = 0 ;
625
626
var revisedExportSet = RemoveRedundantObjects ( unityExportSet ) ;
626
627
int count = GetHierarchyCount ( revisedExportSet ) ;
627
628
628
629
if ( revisedExportSet . Count == 1 ) {
629
630
foreach ( var unityGo in revisedExportSet ) {
630
- i = this . ExportComponents ( unityGo , fbxScene , fbxRootNode , i , count , TransformExportType . Zeroed ) ;
631
- if ( i < 0 ) {
631
+ exportProgress = this . ExportComponents ( unityGo , fbxScene , fbxRootNode , exportProgress , count , TransformExportType . Zeroed ) ;
632
+ if ( exportProgress < 0 ) {
632
633
Debug . LogWarning ( "Export Cancelled" ) ;
633
634
return 0 ;
634
635
}
635
636
}
636
637
}
637
638
else {
638
639
foreach ( var unityGo in revisedExportSet ) {
639
- i = this . ExportComponents ( unityGo , fbxScene , fbxRootNode , i , count ,
640
+ exportProgress = this . ExportComponents ( unityGo , fbxScene , fbxRootNode , exportProgress , count ,
640
641
unityGo . transform . parent == null ? TransformExportType . Local : TransformExportType . Global ) ;
641
- if ( i < 0 ) {
642
+ if ( exportProgress < 0 ) {
642
643
Debug . LogWarning ( "Export Cancelled" ) ;
643
644
return 0 ;
644
645
}
0 commit comments