Skip to content

Commit 9dd89a7

Browse files
committed
export using editor clip display name
1 parent 7de21e1 commit 9dd89a7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ public enum FbxNodeRelationType
188188
/// </summary>
189189
const string UniqueNameFormat = "{0}_{1}";
190190

191+
/// <summary>
192+
/// The animation fbx file format.
193+
/// </summary>
194+
const string AnimFbxFileFormat = "{0}/{1}@{2}.fbx";
195+
191196
/// <summary>
192197
/// Gets the export settings.
193198
/// </summary>
@@ -2922,23 +2927,25 @@ static void OnClipContextClick(MenuCommand command)
29222927
{
29232928
if (obj.GetType().Name.Contains("EditorClip"))
29242929
{
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");
29272931

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");
29312934

29322935
GameObject animationTrackGObject = UnityEditor.Timeline.TimelineEditor.playableDirector.GetGenericBinding (editorClipAnimationTrack) as GameObject;
29332936

2934-
string filePath = folderPath + "/" + animationTrackGObject.name + "@" + timeLineClip.animationClip.name + ".fbx";
2937+
string filePath = string.Format(AnimFbxFileFormat, folderPath, animationTrackGObject.name, timeLineClip.displayName);
29352938
UnityEngine.Object[] myArray = new UnityEngine.Object[] { animationTrackGObject, timeLineClip.animationClip };
29362939

29372940
ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
29382941
}
29392942
}
29402943
}
29412944

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+
29422949
/// <summary>
29432950
/// Add an option "Export all Timeline clips" in the contextual GameObject menu.
29442951
/// </summary>
@@ -2987,7 +2994,7 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
29872994
GameObject atObject = pd.GetGenericBinding(output.sourceObject) as GameObject;
29882995
// One file by animation clip
29892996
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);
29912998
UnityEngine.Object[] myArray = new UnityEngine.Object[] { atObject, timeLineClip.animationClip };
29922999
ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
29933000

0 commit comments

Comments
 (0)