@@ -189,6 +189,11 @@ public enum FbxNodeRelationType
189
189
/// </summary>
190
190
const string UniqueNameFormat = "{0}_{1}" ;
191
191
192
+ /// <summary>
193
+ /// The animation fbx file format.
194
+ /// </summary>
195
+ const string AnimFbxFileFormat = "{0}/{1}@{2}.fbx" ;
196
+
192
197
/// <summary>
193
198
/// Gets the export settings.
194
199
/// </summary>
@@ -2963,23 +2968,25 @@ static void OnClipContextClick(MenuCommand command)
2963
2968
{
2964
2969
if ( obj . GetType ( ) . Name . Contains ( "EditorClip" ) )
2965
2970
{
2966
- var selClip = obj . GetType ( ) . GetProperty ( "clip" ) . GetValue ( obj , null ) ;
2967
- UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
2971
+ var timeLineClip = GetPropertyFromObject < TimelineClip > ( obj , "clip" ) ;
2968
2972
2969
- var selClipItem = obj . GetType ( ) . GetProperty ( "item" ) . GetValue ( obj , null ) ;
2970
- var selClipItemParentTrack = selClipItem . GetType ( ) . GetProperty ( "parentTrack" ) . GetValue ( selClipItem , null ) ;
2971
- AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
2973
+ var selClipItem = GetPropertyFromObject < object > ( obj , "item" ) ;
2974
+ var editorClipAnimationTrack = GetPropertyFromObject < AnimationTrack > ( selClipItem , "parentTrack" ) ;
2972
2975
2973
2976
GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
2974
2977
2975
- string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
2978
+ string filePath = string . Format ( AnimFbxFileFormat , folderPath , animationTrackGObject . name , timeLineClip . displayName ) ;
2976
2979
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
2977
2980
2978
2981
ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
2979
2982
}
2980
2983
}
2981
2984
}
2982
2985
2986
+ private static T GetPropertyFromObject < T > ( object obj , string propertyName ) where T : class {
2987
+ return obj . GetType ( ) . GetProperty ( propertyName ) . GetValue ( obj , null ) as T ;
2988
+ }
2989
+
2983
2990
/// <summary>
2984
2991
/// Add an option "Export all Timeline clips" in the contextual GameObject menu.
2985
2992
/// </summary>
@@ -3028,7 +3035,7 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
3028
3035
GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
3029
3036
// One file by animation clip
3030
3037
foreach ( TimelineClip timeLineClip in at . GetClips ( ) ) {
3031
- string filePath = folderPath + "/" + atObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3038
+ string filePath = string . Format ( AnimFbxFileFormat , folderPath , atObject . name , timeLineClip . animationClip . name ) ;
3032
3039
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
3033
3040
ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3034
3041
0 commit comments