Skip to content

Commit 8dbd08e

Browse files
committed
Merge branch 'UNI-40575-transfer-root-motion' of https://github.com/Unity-Technologies/FbxExporters into UNI-40575-transfer-root-motion
2 parents 132cc43 + c471f3e commit 8dbd08e

19 files changed

+878
-87
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
using UnityEngine;
44
using UnityEditor;
55
using FbxExporters.EditorTools;
6+
#if UNITY_2018_1_OR_NEWER
67
using UnityEditor.Presets;
8+
#endif
79
using System.Linq;
810

911
namespace FbxExporters
@@ -107,12 +109,12 @@ protected override ExportOptionsSettingsSerializeBase SettingsObject
107109
{
108110
get { return ExportSettings.instance.convertToPrefabSettings.info; }
109111
}
110-
112+
#if UNITY_2018_1_OR_NEWER
111113
protected override void ShowPresetReceiver ()
112114
{
113115
ShowPresetReceiver (ExportSettings.instance.convertToPrefabSettings);
114116
}
115-
117+
#endif
116118
protected override void CreateCustomUI ()
117119
{
118120
GUILayout.BeginHorizontal ();

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
using UnityEngine;
44
using UnityEditor;
55
using FbxExporters.EditorTools;
6+
#if UNITY_2018_1_OR_NEWER
67
using UnityEditor.Presets;
8+
#endif
79
using System.Linq;
810

911
namespace FbxExporters
@@ -20,7 +22,7 @@ public abstract class ExportOptionsEditorWindow : EditorWindow
2022
protected const float TextFieldAlignOffset = 3;
2123
protected const float ExportButtonWidth = 100;
2224
protected const float FbxExtOffset = -7;
23-
protected virtual float MinWindowHeight { get { return 250; } }
25+
protected virtual float MinWindowHeight { get { return 300; } }
2426

2527
protected virtual string ExportButtonName { get { return "Export"; } }
2628

@@ -29,8 +31,9 @@ public abstract class ExportOptionsEditorWindow : EditorWindow
2931
protected string m_exportFileName = "";
3032

3133
protected UnityEditor.Editor m_innerEditor;
34+
#if UNITY_2018_1_OR_NEWER
3235
protected FbxExportPresetSelectorReceiver m_receiver;
33-
36+
#endif
3437
private static GUIContent presetIcon { get { return EditorGUIUtility.IconContent ("Preset.Context"); }}
3538
private static GUIStyle presetIconButton { get { return new GUIStyle("IconButton"); }}
3639

@@ -52,7 +55,9 @@ protected UnityEngine.Object[] ToExport {
5255
}
5356

5457
protected virtual void OnEnable(){
58+
#if UNITY_2018_1_OR_NEWER
5559
InitializeReceiver ();
60+
#endif
5661
m_showOptions = true;
5762
this.minSize = new Vector2 (SelectableLabelMinWidth + LabelWidth + BrowseButtonWidth, MinWindowHeight);
5863

@@ -77,6 +82,7 @@ protected virtual void InitializeWindow(string filename = ""){
7782
this.SetFilename (filename);
7883
}
7984

85+
#if UNITY_2018_1_OR_NEWER
8086
protected void InitializeReceiver(){
8187
if (!m_receiver) {
8288
m_receiver = ScriptableObject.CreateInstance<FbxExportPresetSelectorReceiver> () as FbxExportPresetSelectorReceiver;
@@ -86,6 +92,7 @@ protected void InitializeReceiver(){
8692
m_receiver.DialogClosed += SaveExportSettings;
8793
}
8894
}
95+
#endif
8996

9097
public void SetFilename(string filename){
9198
// remove .fbx from end of filename
@@ -116,6 +123,7 @@ public void OnPresetSelectionChanged()
116123
/// </summary>
117124
protected virtual void CreateCustomUI(){}
118125

126+
#if UNITY_2018_1_OR_NEWER
119127
protected abstract void ShowPresetReceiver ();
120128

121129
protected void ShowPresetReceiver(UnityEngine.Object target){
@@ -124,6 +132,7 @@ protected void ShowPresetReceiver(UnityEngine.Object target){
124132
m_receiver.SetInitialValue (new Preset (target));
125133
UnityEditor.Presets.PresetSelector.ShowSelector(target, null, true, m_receiver);
126134
}
135+
#endif
127136

128137
protected Transform TransferAnimationSource {
129138
get {
@@ -238,9 +247,13 @@ protected void OnGUI ()
238247

239248
GUILayout.BeginHorizontal ();
240249
GUILayout.FlexibleSpace ();
250+
251+
#if UNITY_2018_1_OR_NEWER
241252
if(EditorGUILayout.DropdownButton(presetIcon, FocusType.Keyboard, presetIconButton)){
242253
ShowPresetReceiver ();
243254
}
255+
#endif
256+
244257
GUILayout.EndHorizontal();
245258

246259
EditorGUILayout.LabelField("Naming");
@@ -523,10 +536,12 @@ protected override void Export(){
523536
}
524537
}
525538

539+
#if UNITY_2018_1_OR_NEWER
526540
protected override void ShowPresetReceiver ()
527541
{
528542
ShowPresetReceiver (ExportSettings.instance.exportModelSettings);
529543
}
544+
#endif
530545
}
531546
}
532547
}

Assets/FbxExporters/Editor/FbxExportPresetSelectorReceiver.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections;
1+
#if UNITY_2018_1_OR_NEWER
2+
using System.Collections;
23
using System.Collections.Generic;
34
using UnityEngine;
45
using UnityEditor.Presets;
@@ -45,4 +46,5 @@ public void SetTarget(UnityEngine.Object target){
4546
public void SetInitialValue(Preset initialValue){
4647
m_InitialValue = initialValue;
4748
}
48-
}
49+
}
50+
#endif

Assets/FbxExporters/Editor/FbxExportPresetSelectorReceiver.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class ModelExporter : System.IDisposable
8181
// NOTE: The ellipsis at the end of the Menu Item name prevents the context
8282
// from being passed to command, thus resulting in OnContextItem()
8383
// being called only once regardless of what is selected.
84-
const string MenuItemName = "GameObject/Export Model...";
84+
const string MenuItemName = "GameObject/Export To FBX...";
8585
const string ModelOnlyMenuItemName = "GameObject/Export Model Only...";
8686

8787
const string ClipMenuItemName = "GameObject/Export All Recorded Animation Clips...";
@@ -1804,7 +1804,8 @@ protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoo
18041804
}
18051805

18061806
var uniGO = GetGameObject (uniObj);
1807-
if (!uniGO) {
1807+
// Check if the GameObject has an FBX node to the animation. It might be null because the LOD selected doesn't match the one on the gameobject.
1808+
if (!uniGO || MapUnityObjectToFbxNode.ContainsKey(uniGO) == false) {
18081809
continue;
18091810
}
18101811

@@ -3342,41 +3343,6 @@ public static void ExportSingleTimelineClip(TimelineClip timelineClipSelected, G
33423343
ExportModelEditorWindow.Init (exportArray, string.Format (AnimFbxFormat, animationTrackGObject.name, timelineClipSelected.displayName), isTimelineAnim: true);
33433344
}
33443345

3345-
/// <summary>
3346-
/// Add an option " GameObject/Export All Recorded Animation Clips..." in the contextual GameObject menu.
3347-
/// </summary>
3348-
[MenuItem(ClipMenuItemName, false, 31)]
3349-
public static void OnPlayableDirectorGameObjectContextClick(MenuCommand command)
3350-
{
3351-
Object[] selection = null;
3352-
3353-
if (command == null || command.context == null)
3354-
{
3355-
// We were actually invoked from the top GameObject menu, so use the selection.
3356-
selection = Selection.GetFiltered<Object>(SelectionMode.Editable | SelectionMode.TopLevel);
3357-
}
3358-
else
3359-
{
3360-
// We were invoked from the right-click menu, so use the context of the context menu.
3361-
GameObject selected = command.context as GameObject;
3362-
if (selected)
3363-
{
3364-
selection = new GameObject[] { selected };
3365-
}
3366-
}
3367-
3368-
var playableDirectors = new List<UnityEngine.Object> ();
3369-
foreach (GameObject objectWithPlayableDirector in selection)
3370-
{
3371-
PlayableDirector pd = objectWithPlayableDirector.GetComponent<PlayableDirector>();
3372-
if (pd == null) {
3373-
continue;
3374-
}
3375-
playableDirectors.Add (objectWithPlayableDirector);
3376-
}
3377-
ExportModelEditorWindow.Init (playableDirectors, "(automatic)", isTimelineAnim:true, isPlayableDirector:true);
3378-
}
3379-
33803346
public static void ExportAllTimelineClips(GameObject objectWithPlayableDirector, string folderPath, IExportOptions exportOptions = null)
33813347
{
33823348
PlayableDirector pd = objectWithPlayableDirector.GetComponent<PlayableDirector>();
@@ -3402,31 +3368,6 @@ public static void ExportAllTimelineClips(GameObject objectWithPlayableDirector,
34023368
}
34033369
}
34043370
}
3405-
3406-
/// <summary>
3407-
/// Validate the menu item defined by the function OnPlayableDirectorGameObjectContextClick.
3408-
/// </summary>
3409-
[MenuItem(ClipMenuItemName, true, 31)]
3410-
public static bool ValidateClipContextClick()
3411-
{
3412-
Object[] selection = Selection.objects;
3413-
3414-
if (selection == null || selection.Length == 0)
3415-
{
3416-
return false;
3417-
}
3418-
3419-
foreach (Object obj in selection)
3420-
{
3421-
GameObject gameObj = obj as GameObject;
3422-
if (gameObj != null && gameObj.GetComponent<PlayableDirector>() != null)
3423-
{
3424-
return true;
3425-
}
3426-
}
3427-
3428-
return false;
3429-
}
34303371

34313372
/// <summary>
34323373
/// Add a menu item "Export Model..." to a GameObject's context menu.

Assets/FbxExporters/Editor/UnitTests/ExportTimelineClipTest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FbxExporters/Editor/UnitTests/FbxCameraTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FbxExporters/Editor/UnitTests/Models/Cowboy/cowboyMidPoly(riged).FBX.meta

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)