@@ -195,6 +195,19 @@ public static EditorTools.ExportSettings ExportSettings {
195
195
get { return EditorTools . ExportSettings . instance ; }
196
196
}
197
197
198
+
199
+ private EditorTools . IExportOptions m_exportOptions ;
200
+ private EditorTools . IExportOptions ExportOptions {
201
+ get {
202
+ if ( m_exportOptions == null ) {
203
+ // get default settings;
204
+ m_exportOptions = ScriptableObject . CreateInstance < ExportModelSettings > ( ) as ExportModelSettings ;
205
+ }
206
+ return m_exportOptions ;
207
+ }
208
+ set { m_exportOptions = value ; }
209
+ }
210
+
198
211
/// <summary>
199
212
/// Gets the Unity default material.
200
213
/// </summary>
@@ -621,7 +634,7 @@ public bool ExportMaterial (Material unityMaterial, FbxScene fbxScene, FbxNode f
621
634
return true ;
622
635
}
623
636
624
- var fbxName = ExportSettings . UseMayaCompatibleNames ( )
637
+ var fbxName = ExportOptions . UseMayaCompatibleNames ( )
625
638
? ConvertToMayaCompatibleName ( unityName ) : unityName ;
626
639
627
640
if ( Verbose ) {
@@ -1928,7 +1941,7 @@ protected int ExportTransformHierarchy(
1928
1941
{
1929
1942
int numObjectsExported = exportProgress ;
1930
1943
1931
- if ( ExportSettings . UseMayaCompatibleNames ( ) ) {
1944
+ if ( ExportOptions . UseMayaCompatibleNames ( ) ) {
1932
1945
unityGo . name = ConvertToMayaCompatibleName ( unityGo . name ) ;
1933
1946
}
1934
1947
@@ -2189,7 +2202,7 @@ private bool ExportGameObjectAndParents(
2189
2202
return true ;
2190
2203
}
2191
2204
2192
- if ( ExportSettings . UseMayaCompatibleNames ( ) ) {
2205
+ if ( ExportOptions . UseMayaCompatibleNames ( ) ) {
2193
2206
unityGo . name = ConvertToMayaCompatibleName ( unityGo . name ) ;
2194
2207
}
2195
2208
@@ -2705,9 +2718,7 @@ public enum TransformExportType { Local, Global, Reset };
2705
2718
/// </summary>
2706
2719
public int ExportAll (
2707
2720
IEnumerable < UnityEngine . Object > unityExportSet ,
2708
- Dictionary < GameObject , AnimationOnlyExportData > animationExportData ,
2709
- TransformExportType exportType = TransformExportType . Global ,
2710
- ExportModelSettingsSerialize . LODExportType lodExportType = ExportModelSettingsSerialize . LODExportType . All )
2721
+ Dictionary < GameObject , AnimationOnlyExportData > animationExportData )
2711
2722
{
2712
2723
exportCancelled = false ;
2713
2724
@@ -2740,7 +2751,7 @@ public int ExportAll (
2740
2751
// Initialize the exporter.
2741
2752
// fileFormat must be binary if we are embedding textures
2742
2753
int fileFormat = - 1 ;
2743
- if ( EditorTools . ExportSettings . GetExportFormat ( ) == ExportModelSettingsSerialize . ExportFormat . ASCII )
2754
+ if ( ExportOptions . GetExportFormat ( ) == ExportModelSettingsSerialize . ExportFormat . ASCII )
2744
2755
{
2745
2756
fileFormat = fbxManager . GetIOPluginRegistry ( ) . FindWriterIDByDescription ( "FBX ascii (*.fbx)" ) ;
2746
2757
}
@@ -2811,23 +2822,25 @@ public int ExportAll (
2811
2822
}
2812
2823
2813
2824
Vector3 center = Vector3 . zero ;
2814
- if ( exportType == TransformExportType . Global ) {
2815
- switch ( ExportSettings . GetObjectPosition ( ) ) {
2816
- case ExportModelSettingsSerialize . ObjectPosition . LocalCentered :
2817
- // one object to export -> move to (0,0,0)
2818
- if ( revisedExportSet . Count == 1 ) {
2819
- var tempList = new List < GameObject > ( revisedExportSet ) ;
2820
- center = tempList [ 0 ] . transform . position ;
2821
- break ;
2822
- }
2823
- // more than one object to export -> get bounding center
2824
- center = FindCenter ( revisedExportSet ) ;
2825
- break ;
2826
- // absolute center -> don't do anything
2827
- default :
2828
- center = Vector3 . zero ;
2825
+ TransformExportType exportType = TransformExportType . Global ;
2826
+ switch ( ExportOptions . GetObjectPosition ( ) ) {
2827
+ case ExportModelSettingsSerialize . ObjectPosition . LocalCentered :
2828
+ // one object to export -> move to (0,0,0)
2829
+ if ( revisedExportSet . Count == 1 ) {
2830
+ var tempList = new List < GameObject > ( revisedExportSet ) ;
2831
+ center = tempList [ 0 ] . transform . position ;
2829
2832
break ;
2830
2833
}
2834
+ // more than one object to export -> get bounding center
2835
+ center = FindCenter ( revisedExportSet ) ;
2836
+ break ;
2837
+ case ExportModelSettingsSerialize . ObjectPosition . Reset :
2838
+ exportType = TransformExportType . Reset ;
2839
+ break ;
2840
+ // absolute center -> don't do anything
2841
+ default :
2842
+ center = Vector3 . zero ;
2843
+ break ;
2831
2844
}
2832
2845
2833
2846
foreach ( var unityGo in revisedExportSet ) {
@@ -2837,7 +2850,7 @@ public int ExportAll (
2837
2850
}
2838
2851
else {
2839
2852
exportProgress = this . ExportTransformHierarchy ( unityGo , fbxScene , fbxRootNode ,
2840
- exportProgress , count , center , exportType , lodExportType ) ;
2853
+ exportProgress , count , center , exportType , ExportOptions . GetLODExportType ( ) ) ;
2841
2854
}
2842
2855
if ( exportCancelled || exportProgress < 0 ) {
2843
2856
Debug . LogWarning ( "Export Cancelled" ) ;
@@ -3001,7 +3014,7 @@ public static void ExportSingleTimelineClip(TimelineClip timelineClipSelected, G
3001
3014
animationTrackGObject ,
3002
3015
timelineClipSelected . animationClip
3003
3016
} ;
3004
- ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3017
+ // ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
3005
3018
}
3006
3019
3007
3020
/// <summary>
@@ -3060,7 +3073,7 @@ public static void ExportAllTimelineClips(GameObject objectWithPlayableDirector,
3060
3073
foreach ( TimelineClip timeLineClip in at . GetClips ( ) ) {
3061
3074
string filePath = string . Format ( AnimFbxFileFormat , folderPath , atObject . name , timeLineClip . displayName ) ;
3062
3075
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
3063
- ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3076
+ // ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
3064
3077
}
3065
3078
}
3066
3079
}
@@ -3611,18 +3624,9 @@ private static string GetExportFilePath(string filenameSuggestion = ""){
3611
3624
private static void OnExport ( AnimationExportType exportType = AnimationExportType . all )
3612
3625
{
3613
3626
GameObject [ ] selectedGOs = Selection . GetFiltered < GameObject > ( SelectionMode . TopLevel ) ;
3614
- string filename = null ;
3615
- if ( selectedGOs . Length == 1 ) {
3616
- filename = ConvertToValidFilename ( selectedGOs [ 0 ] . name + "." + kFBXFileExtension ) ;
3617
- } else {
3618
- filename = string . IsNullOrEmpty ( LastFilePath )
3619
- ? MakeFileName ( basename : FileBaseName , extension : kFBXFileExtension )
3620
- : System . IO . Path . GetFileName ( LastFilePath ) ;
3621
- }
3622
3627
3623
- var hierarchyCount = ModelExporter . RemoveRedundantObjects ( selectedGOs ) . Count ;
3624
-
3625
- ExportModelEditorWindow . Init ( filename , singleHierarchyExport : hierarchyCount == 1 , exportType : exportType ) ;
3628
+ var toExport = ModelExporter . RemoveRedundantObjects ( selectedGOs ) ;
3629
+ ExportModelEditorWindow . Init ( System . Linq . Enumerable . Cast < UnityEngine . Object > ( toExport ) , exportType : exportType ) ;
3626
3630
}
3627
3631
3628
3632
/// <summary>
@@ -3632,21 +3636,20 @@ private static void OnExport (AnimationExportType exportType = AnimationExportTy
3632
3636
public static string ExportObjects (
3633
3637
string filePath ,
3634
3638
UnityEngine . Object [ ] objects = null ,
3635
- AnimationExportType exportType = AnimationExportType . all ,
3636
- TransformExportType transformExportType = TransformExportType . Global ,
3637
- ExportModelSettingsSerialize . LODExportType lodExportType = ExportModelSettingsSerialize . LODExportType . All )
3639
+ IExportOptions exportOptions = null ,
3640
+ AnimationExportType exportType = AnimationExportType . all )
3638
3641
{
3639
3642
LastFilePath = filePath ;
3640
3643
3641
3644
using ( var fbxExporter = Create ( ) ) {
3642
3645
// ensure output directory exists
3643
3646
EnsureDirectory ( filePath ) ;
3647
+ fbxExporter . ExportOptions = exportOptions ;
3644
3648
3645
3649
if ( objects == null ) {
3646
3650
objects = Selection . objects ;
3647
3651
}
3648
3652
3649
-
3650
3653
Dictionary < GameObject , AnimationOnlyExportData > animationExportData = null ;
3651
3654
switch ( exportType )
3652
3655
{
@@ -3675,7 +3678,7 @@ public static string ExportObjects (
3675
3678
break ;
3676
3679
}
3677
3680
3678
- if ( fbxExporter . ExportAll ( objects , animationExportData , transformExportType , lodExportType ) > 0 ) {
3681
+ if ( fbxExporter . ExportAll ( objects , animationExportData ) > 0 ) {
3679
3682
string message = string . Format ( "Successfully exported: {0}" , filePath ) ;
3680
3683
UnityEngine . Debug . Log ( message ) ;
3681
3684
@@ -3687,11 +3690,10 @@ public static string ExportObjects (
3687
3690
3688
3691
public static string ExportObject (
3689
3692
string filePath , UnityEngine . Object root ,
3690
- AnimationExportType exportType = AnimationExportType . all ,
3691
- TransformExportType transformExportType = TransformExportType . Reset ,
3692
- ExportModelSettingsSerialize . LODExportType lodExportType = ExportModelSettingsSerialize . LODExportType . All )
3693
+ IExportOptions exportOptions = null ,
3694
+ AnimationExportType exportType = AnimationExportType . all )
3693
3695
{
3694
- return ExportObjects ( filePath , new Object [ ] { root } , exportType , transformExportType , lodExportType ) ;
3696
+ return ExportObjects ( filePath , new Object [ ] { root } , exportOptions , exportType : exportType ) ;
3695
3697
}
3696
3698
3697
3699
private static void EnsureDirectory ( string path )
0 commit comments