@@ -85,7 +85,6 @@ public class ModelExporter : System.IDisposable
85
85
const string ClipMenuItemName = "GameObject/Export All Timeline Clips..." ;
86
86
const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip..." ;
87
87
88
-
89
88
const string AnimOnlyMenuItemName = "GameObject/Export Animation Only" ;
90
89
91
90
const string FileBaseName = "Untitled" ;
@@ -1337,7 +1336,7 @@ protected bool ExportLight (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNo
1337
1336
if ( ! MapLightType . TryGetValue ( unityLight . type , out fbxLightType ) )
1338
1337
return false ;
1339
1338
1340
- FbxLight fbxLight = FbxLight . Create ( fbxScene . GetFbxManager ( ) , unityLight . name ) ;
1339
+ FbxLight fbxLight = FbxLight . Create ( fbxScene . GetFbxManager ( ) , unityLight . name ) ;
1341
1340
1342
1341
// Set the type of the light.
1343
1342
fbxLight . LightType . Set ( fbxLightType ) ;
@@ -2528,7 +2527,7 @@ protected Dictionary<GameObject, AnimationOnlyExportData> GetTimelineAnimationEx
2528
2527
return data ;
2529
2528
}
2530
2529
2531
- protected Dictionary < GameObject , AnimationOnlyExportData > GetAnimationExportData ( HashSet < GameObject > exportSet )
2530
+ protected Dictionary < GameObject , AnimationOnlyExportData > GetAnimationExportData ( HashSet < GameObject > exportSet )
2532
2531
{
2533
2532
Dictionary < GameObject , AnimationOnlyExportData > hierarchyToExportData = new Dictionary < GameObject , AnimationOnlyExportData > ( ) ;
2534
2533
@@ -2613,8 +2612,6 @@ protected Dictionary<GameObject, AnimationOnlyExportData> GetAnimationExportData
2613
2612
return hierarchyToExportData ;
2614
2613
}
2615
2614
2616
-
2617
-
2618
2615
/// <summary>
2619
2616
/// Export components on this game object.
2620
2617
/// Transform components have already been exported.
@@ -2824,7 +2821,7 @@ public enum TransformExportType { Local, Global, Reset };
2824
2821
///
2825
2822
/// This refreshes the asset database.
2826
2823
/// </summary>
2827
- public int ExportAll ( IEnumerable < UnityEngine . Object > unityExportSet , Dictionary < GameObject , AnimationOnlyExportData > animationExportData /*, bool animOnly = false*/ )
2824
+ public int ExportAll ( IEnumerable < UnityEngine . Object > unityExportSet , Dictionary < GameObject , AnimationOnlyExportData > animationExportData )
2828
2825
{
2829
2826
exportCancelled = false ;
2830
2827
@@ -3057,7 +3054,10 @@ private void ReplaceFile ()
3057
3054
}
3058
3055
}
3059
3056
3060
- [ MenuItem ( TimelineClipMenuItemName , false , 31 ) ]
3057
+ /// <summary>
3058
+ /// Add an option "Export selected Timeline clip" in the contextual GameObject menu.
3059
+ /// </summary>
3060
+ [ MenuItem ( TimelineClipMenuItemName , false , 31 ) ]
3061
3061
static void OnClipContextClick ( MenuCommand command )
3062
3062
{
3063
3063
// Now that we know we have stuff to export, get the user-desired path.
@@ -3072,27 +3072,22 @@ static void OnClipContextClick(MenuCommand command)
3072
3072
{
3073
3073
return ;
3074
3074
}
3075
- Debug . Log ( folderPath ) ;
3076
-
3077
3075
3078
3076
var selectedObjects = Selection . objects ;
3079
3077
foreach ( var obj in selectedObjects )
3080
3078
{
3081
3079
if ( obj . GetType ( ) . Name . Contains ( "EditorClip" ) )
3082
3080
{
3083
3081
var selClip = obj . GetType ( ) . GetProperty ( "clip" ) . GetValue ( obj , null ) ;
3084
- UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
3082
+ UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
3085
3083
3086
3084
var selClipItem = obj . GetType ( ) . GetProperty ( "item" ) . GetValue ( obj , null ) ;
3087
3085
var selClipItemParentTrack = selClipItem . GetType ( ) . GetProperty ( "parentTrack" ) . GetValue ( selClipItem , null ) ;
3088
3086
AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
3089
3087
3090
3088
GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
3091
3089
3092
- Debug . Log ( "obj name: " + obj . name + " /clip name: " + editorClipAnimationTrack . name + " /timelineAssetName: " + animationTrackGObject . name ) ;
3093
-
3094
3090
string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3095
- Debug . Log ( "filepath: " + filePath ) ;
3096
3091
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
3097
3092
3098
3093
ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
@@ -3103,7 +3098,7 @@ static void OnClipContextClick(MenuCommand command)
3103
3098
3104
3099
3105
3100
/// <summary>
3106
- /// Add an option "Update from FBX " in the contextual GameObject menu.
3101
+ /// Add an option "Export all Timeline clips " in the contextual GameObject menu.
3107
3102
/// </summary>
3108
3103
[ MenuItem ( ClipMenuItemName , false , 31 ) ]
3109
3104
static void OnGameObjectWithTimelineContextClick ( MenuCommand command )
@@ -3151,12 +3146,15 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
3151
3146
AnimationTrack at = output . sourceObject as AnimationTrack ;
3152
3147
3153
3148
GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
3149
+ // One file by animation clip
3150
+ foreach ( TimelineClip timeLineClip in at . GetClips ( ) )
3151
+ {
3152
+ string filePath = folderPath + "/" + atObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3153
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
3154
+ Debug . Log ( "filepath: " + filePath ) ;
3155
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3154
3156
3155
- string filePath = folderPath + "/" + atObject . name + "@" + at . name + ".fbx" ;
3156
- Debug . Log ( "filepath: " + filePath ) ;
3157
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , at } ;
3158
-
3159
- ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationTrack ) ;
3157
+ }
3160
3158
}
3161
3159
}
3162
3160
}
@@ -3187,8 +3185,8 @@ public static bool ValidateClipContextClick()
3187
3185
return false ;
3188
3186
}
3189
3187
3190
- /// <summary>
3191
- /// Add a menu item to a GameObject's context menu.
3188
+ /// <summary>
3189
+ /// Add a menu item "Export Model..." to a GameObject's context menu.
3192
3190
/// </summary>
3193
3191
/// <param name="command">Command.</param>
3194
3192
[ MenuItem ( MenuItemName , false , 30 ) ]
@@ -3211,7 +3209,7 @@ public static bool OnValidateMenuItem ()
3211
3209
}
3212
3210
3213
3211
/// <summary>
3214
- /// Add a menu item to a GameObject's context menu.
3212
+ /// Add a menu item "Export Animation Only" to a GameObject's context menu.
3215
3213
/// </summary>
3216
3214
/// <param name="command">Command.</param>
3217
3215
[ MenuItem ( AnimOnlyMenuItemName , false , 30 ) ]
0 commit comments