@@ -3058,7 +3058,10 @@ private void ReplaceFile ()
3058
3058
Debug . LogWarning ( string . Format ( "Failed to move file {0} to {1}" , m_tempFilePath , m_lastFilePath ) ) ;
3059
3059
}
3060
3060
}
3061
-
3061
+ /// <summary>
3062
+ /// GameObject/Export Selected Timeline Clip...
3063
+ /// </summary>
3064
+ /// <param name="command"></param>
3062
3065
[ MenuItem ( TimelineClipMenuItemName , false , 31 ) ]
3063
3066
static void OnClipContextClick ( MenuCommand command )
3064
3067
{
@@ -3078,37 +3081,40 @@ static void OnClipContextClick(MenuCommand command)
3078
3081
3079
3082
3080
3083
var selectedObjects = Selection . objects ;
3081
- foreach ( var obj in selectedObjects )
3084
+ foreach ( GameObject obj in selectedObjects )
3082
3085
{
3083
- if ( obj . GetType ( ) . Name . Contains ( "EditorClip" ) )
3084
- {
3085
- var selClip = obj . GetType ( ) . GetProperty ( "clip" ) . GetValue ( obj , null ) ;
3086
- UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
3087
-
3088
- var selClipItem = obj . GetType ( ) . GetProperty ( "item" ) . GetValue ( obj , null ) ;
3089
- var selClipItemParentTrack = selClipItem . GetType ( ) . GetProperty ( "parentTrack" ) . GetValue ( selClipItem , null ) ;
3090
- AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
3086
+ ExportSingleTimelineClip ( obj , folderPath ) ;
3087
+ }
3088
+ }
3091
3089
3092
- GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
3090
+ public static void ExportSingleTimelineClip ( GameObject obj , string folderPath )
3091
+ {
3092
+ if ( obj . GetType ( ) . Name . Contains ( "EditorClip" ) )
3093
+ {
3094
+ var selClip = obj . GetType ( ) . GetProperty ( "clip" ) . GetValue ( obj , null ) ;
3095
+ UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
3093
3096
3094
- Debug . Log ( "obj name: " + obj . name + " /clip name: " + editorClipAnimationTrack . name + " /timelineAssetName: " + animationTrackGObject . name ) ;
3097
+ var selClipItem = obj . GetType ( ) . GetProperty ( "item" ) . GetValue ( obj , null ) ;
3098
+ var selClipItemParentTrack = selClipItem . GetType ( ) . GetProperty ( "parentTrack" ) . GetValue ( selClipItem , null ) ;
3099
+ AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
3095
3100
3096
- string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3097
- Debug . Log ( "filepath: " + filePath ) ;
3098
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
3101
+ GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
3099
3102
3100
- ExportObjects ( filePath , myArray , ExportType . timelineAnimationClip ) ;
3101
- }
3102
- }
3103
- }
3103
+ Debug . Log ( "obj name: " + obj . name + " /clip name: " + editorClipAnimationTrack . name + " /timelineAssetName: " + animationTrackGObject . name ) ;
3104
3104
3105
+ string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3106
+ Debug . Log ( "filepath: " + filePath ) ;
3107
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
3105
3108
3109
+ ExportObjects ( filePath , myArray , ExportType . timelineAnimationClip ) ;
3110
+ }
3111
+ }
3106
3112
3107
3113
/// <summary>
3108
- /// Add an option "Update from FBX" in the contextual GameObject menu .
3114
+ /// GameObject/Export All Recorded Animation Clips.. .
3109
3115
/// </summary>
3110
3116
[ MenuItem ( ClipMenuItemName , false , 31 ) ]
3111
- static void OnGameObjectWithTimelineContextClick ( MenuCommand command )
3117
+ public static void OnPlayableDirectorGameObjectContextClick ( MenuCommand command )
3112
3118
{
3113
3119
// Now that we know we have stuff to export, get the user-desired path.
3114
3120
string directory = string . IsNullOrEmpty ( LastFilePath )
@@ -3143,23 +3149,29 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
3143
3149
3144
3150
foreach ( GameObject obj in selection )
3145
3151
{
3146
- Debug . Log ( obj . GetType ( ) . BaseType . ToString ( ) + ":" + obj . name ) ;
3152
+ ExportAllTimelineClips ( obj , folderPath ) ;
3153
+ }
3154
+ }
3155
+
3147
3156
3148
- PlayableDirector pd = obj . GetComponent < PlayableDirector > ( ) ;
3149
- if ( pd != null )
3157
+ public static void ExportAllTimelineClips ( GameObject obj , string folderPath )
3158
+ {
3159
+ Debug . Log ( obj . GetType ( ) . BaseType . ToString ( ) + ":" + obj . name ) ;
3160
+
3161
+ PlayableDirector pd = obj . GetComponent < PlayableDirector > ( ) ;
3162
+ if ( pd != null )
3163
+ {
3164
+ foreach ( PlayableBinding output in pd . playableAsset . outputs )
3150
3165
{
3151
- foreach ( PlayableBinding output in pd . playableAsset . outputs )
3152
- {
3153
- AnimationTrack at = output . sourceObject as AnimationTrack ;
3166
+ AnimationTrack at = output . sourceObject as AnimationTrack ;
3154
3167
3155
- GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
3168
+ GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
3156
3169
3157
- string filePath = folderPath + "/" + atObject . name + "@" + at . name + ".fbx" ;
3158
- Debug . Log ( "filepath: " + filePath ) ;
3159
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , at } ;
3170
+ string filePath = folderPath + "/" + atObject . name + "@" + at . name + ".fbx" ;
3171
+ Debug . Log ( "filepath: " + filePath ) ;
3172
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , at } ;
3160
3173
3161
- ExportObjects ( filePath , myArray , ExportType . timelineAnimationTrack ) ;
3162
- }
3174
+ ExportObjects ( filePath , myArray , ExportType . timelineAnimationTrack ) ;
3163
3175
}
3164
3176
}
3165
3177
}
0 commit comments