@@ -82,6 +82,7 @@ public class ModelExporter : System.IDisposable
82
82
// from being passed to command, thus resulting in OnContextItem()
83
83
// being called only once regardless of what is selected.
84
84
const string MenuItemName = "GameObject/Export Model..." ;
85
+ const string ModelOnlyMenuItemName = "GameObject/Export Model Only..." ;
85
86
86
87
const string ClipMenuItemName = "GameObject/Export All Recorded Animation Clips..." ;
87
88
const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip..." ;
@@ -2512,7 +2513,7 @@ protected Dictionary<GameObject, AnimationOnlyExportData> GetAnimationExportData
2512
2513
/// Transform components have already been exported.
2513
2514
/// This function exports the other components and animation.
2514
2515
/// </summary>
2515
- protected bool ExportComponents ( FbxScene fbxScene )
2516
+ protected bool ExportComponents ( FbxScene fbxScene , AnimationExportType animationExportType = AnimationExportType . all )
2516
2517
{
2517
2518
var animationNodes = new HashSet < GameObject > ( ) ;
2518
2519
@@ -2551,7 +2552,7 @@ protected bool ExportComponents(FbxScene fbxScene)
2551
2552
2552
2553
// check if this object contains animation, keep track of it
2553
2554
// if it does
2554
- if ( GameObjectHasAnimation ( unityGo ) ) {
2555
+ if ( animationExportType != AnimationExportType . none && GameObjectHasAnimation ( unityGo ) ) {
2555
2556
animationNodes . Add ( unityGo ) ;
2556
2557
}
2557
2558
}
@@ -2718,7 +2719,8 @@ public enum TransformExportType { Local, Global, Reset };
2718
2719
/// </summary>
2719
2720
public int ExportAll (
2720
2721
IEnumerable < UnityEngine . Object > unityExportSet ,
2721
- Dictionary < GameObject , AnimationOnlyExportData > animationExportData )
2722
+ Dictionary < GameObject , AnimationOnlyExportData > animationExportData
2723
+ AnimationExportType animationExportType = AnimationExportType . all )
2722
2724
{
2723
2725
exportCancelled = false ;
2724
2726
@@ -2846,7 +2848,7 @@ public int ExportAll (
2846
2848
foreach ( var unityGo in revisedExportSet ) {
2847
2849
AnimationOnlyExportData data ;
2848
2850
if ( animOnly && animationExportData . TryGetValue ( unityGo , out data ) ) {
2849
- exportProgress = this . ExportAnimationOnly ( unityGo , fbxScene , exportProgress , count , center , data , exportType ) ;
2851
+ exportProgress = this . ExportAnimationOnly ( unityGo , fbxScene , exportProgress , count , center , data , transformExportType ) ;
2850
2852
}
2851
2853
else {
2852
2854
exportProgress = this . ExportTransformHierarchy ( unityGo , fbxScene , fbxRootNode ,
@@ -2859,7 +2861,7 @@ public int ExportAll (
2859
2861
}
2860
2862
2861
2863
if ( ! animOnly ) {
2862
- if ( ! ExportComponents ( fbxScene ) ) {
2864
+ if ( ! ExportComponents ( fbxScene , animationExportType ) ) {
2863
2865
Debug . LogWarning ( "Export Cancelled" ) ;
2864
2866
return 0 ;
2865
2867
}
@@ -3127,6 +3129,30 @@ public static bool OnValidateMenuItem ()
3127
3129
return true ;
3128
3130
}
3129
3131
3132
+ /// <summary>
3133
+ /// Add a menu item "Export Model Only..." to a GameObject's context menu.
3134
+ /// </summary>
3135
+ /// <param name="command">Command.</param>
3136
+ [ MenuItem ( ModelOnlyMenuItemName , false , 30 ) ]
3137
+ static void ModelOnlyOnContextItem ( MenuCommand command )
3138
+ {
3139
+ if ( Selection . objects . Length <= 0 ) {
3140
+ DisplayNoSelectionDialog ( ) ;
3141
+ return ;
3142
+ }
3143
+ OnExport ( AnimationExportType . none ) ;
3144
+ }
3145
+
3146
+ /// <summary>
3147
+ /// Validate the menu item defined by the function above.
3148
+ /// </summary>
3149
+ [ MenuItem ( ModelOnlyMenuItemName , true , 30 ) ]
3150
+ public static bool ModelOnlyOnValidateMenuItem ( )
3151
+ {
3152
+ return true ;
3153
+ }
3154
+
3155
+
3130
3156
/// <summary>
3131
3157
/// Add a menu item "Export Animation Only" to a GameObject's context menu.
3132
3158
/// </summary>
@@ -3601,7 +3627,8 @@ public enum AnimationExportType{
3601
3627
timelineAnimationClip ,
3602
3628
timelineAnimationTrack ,
3603
3629
componentAnimation ,
3604
- all
3630
+ all ,
3631
+ none
3605
3632
}
3606
3633
3607
3634
@@ -3651,7 +3678,7 @@ public static string ExportObjects (
3651
3678
}
3652
3679
3653
3680
Dictionary < GameObject , AnimationOnlyExportData > animationExportData = null ;
3654
- switch ( exportType )
3681
+ switch ( animationExportType )
3655
3682
{
3656
3683
case AnimationExportType . timelineAnimationClip :
3657
3684
// We expect the first argument in the list to be the GameObject, the second one is the Animation Clip/Track we are exporting from the timeline
@@ -3678,7 +3705,7 @@ public static string ExportObjects (
3678
3705
break ;
3679
3706
}
3680
3707
3681
- if ( fbxExporter . ExportAll ( objects , animationExportData ) > 0 ) {
3708
+ if ( fbxExporter . ExportAll ( objects , animationExportData , animationExportType ) > 0 ) {
3682
3709
string message = string . Format ( "Successfully exported: {0}" , filePath ) ;
3683
3710
UnityEngine . Debug . Log ( message ) ;
3684
3711
0 commit comments