Skip to content

Commit 1db7c4f

Browse files
committed
fix export timeline clip
- animation track object could be a GameObject or an Animator. Make sure to handle both cases
1 parent 0597da2 commit 1db7c4f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Assets/com.unity.formats.fbx/Editor/Scripts/FbxExporter.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ protected bool ExportInstance (GameObject unityGo, FbxNode fbxNode, FbxScene fbx
12511251
if (unityPrefabType != PrefabType.PrefabInstance &&
12521252
unityPrefabType != PrefabType.ModelPrefabInstance) return false;
12531253

1254-
Object unityPrefabParent = PrefabUtility.GetPrefabParent (unityGo);
1254+
Object unityPrefabParent = PrefabUtility.GetCorrespondingObjectFromSource (unityGo);
12551255

12561256
if (Verbose)
12571257
Debug.Log (string.Format ("exporting instance {0}({1})", unityGo.name, unityPrefabParent.name));
@@ -3305,9 +3305,24 @@ protected static bool ExportSingleEditorClip(Object editorClipSelected)
33053305
object selClipItem = editorClipSelected.GetType().GetProperty("item").GetValue(editorClipSelected, null);
33063306
object selClipItemParentTrack = selClipItem.GetType().GetProperty("parentTrack").GetValue(selClipItem, null);
33073307
AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack;
3308-
GameObject animationTrackGObject = UnityEditor.Timeline.TimelineEditor.playableDirector.GetGenericBinding (editorClipAnimationTrack) as GameObject;
3308+
Object animationTrackObject = UnityEditor.Timeline.TimelineEditor.inspectedDirector.GetGenericBinding (editorClipAnimationTrack);
3309+
GameObject animationTrackGO = null;
3310+
if (animationTrackObject is GameObject)
3311+
{
3312+
animationTrackGO = animationTrackObject as GameObject;
3313+
}
3314+
else if (animationTrackObject is Animator)
3315+
{
3316+
animationTrackGO = (animationTrackObject as Animator).gameObject;
3317+
}
3318+
3319+
if(animationTrackGO == null)
3320+
{
3321+
Debug.LogErrorFormat("Could not export animation track object of type {0}", animationTrackObject.GetType().Name);
3322+
return false;
3323+
}
33093324

3310-
ExportSingleTimelineClip(timeLineClip, animationTrackGObject);
3325+
ExportSingleTimelineClip(timeLineClip, animationTrackGO);
33113326
return true;
33123327
}
33133328
return false;

0 commit comments

Comments
 (0)