@@ -188,6 +188,11 @@ public enum FbxNodeRelationType
188
188
/// </summary>
189
189
const string UniqueNameFormat = "{0}_{1}" ;
190
190
191
+ /// <summary>
192
+ /// The animation fbx file format.
193
+ /// </summary>
194
+ const string AnimFbxFileFormat = "{0}/{1}@{2}.fbx" ;
195
+
191
196
/// <summary>
192
197
/// Gets the export settings.
193
198
/// </summary>
@@ -2922,23 +2927,25 @@ static void OnClipContextClick(MenuCommand command)
2922
2927
{
2923
2928
if ( obj . GetType ( ) . Name . Contains ( "EditorClip" ) )
2924
2929
{
2925
- var selClip = obj . GetType ( ) . GetProperty ( "clip" ) . GetValue ( obj , null ) ;
2926
- UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
2930
+ var timeLineClip = GetPropertyFromObject < TimelineClip > ( obj , "clip" ) ;
2927
2931
2928
- var selClipItem = obj . GetType ( ) . GetProperty ( "item" ) . GetValue ( obj , null ) ;
2929
- var selClipItemParentTrack = selClipItem . GetType ( ) . GetProperty ( "parentTrack" ) . GetValue ( selClipItem , null ) ;
2930
- AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
2932
+ var selClipItem = GetPropertyFromObject < object > ( obj , "item" ) ;
2933
+ var editorClipAnimationTrack = GetPropertyFromObject < AnimationTrack > ( selClipItem , "parentTrack" ) ;
2931
2934
2932
2935
GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
2933
2936
2934
- string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
2937
+ string filePath = string . Format ( AnimFbxFileFormat , folderPath , animationTrackGObject . name , timeLineClip . displayName ) ;
2935
2938
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
2936
2939
2937
2940
ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
2938
2941
}
2939
2942
}
2940
2943
}
2941
2944
2945
+ private static T GetPropertyFromObject < T > ( object obj , string propertyName ) where T : class {
2946
+ return obj . GetType ( ) . GetProperty ( propertyName ) . GetValue ( obj , null ) as T ;
2947
+ }
2948
+
2942
2949
/// <summary>
2943
2950
/// Add an option "Export all Timeline clips" in the contextual GameObject menu.
2944
2951
/// </summary>
@@ -2987,7 +2994,7 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
2987
2994
GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
2988
2995
// One file by animation clip
2989
2996
foreach ( TimelineClip timeLineClip in at . GetClips ( ) ) {
2990
- string filePath = folderPath + "/" + atObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
2997
+ string filePath = string . Format ( AnimFbxFileFormat , folderPath , atObject . name , timeLineClip . animationClip . name ) ;
2991
2998
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
2992
2999
ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
2993
3000
0 commit comments