Skip to content

Commit e5a2d10

Browse files
committed
Merge branch 'master' into UNI-41969-restore-include-setting
2 parents 76b6c33 + 99c2e0a commit e5a2d10

File tree

9 files changed

+658
-143
lines changed

9 files changed

+658
-143
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ namespace Editor
1515
public class ConvertToPrefabEditorWindow : ExportOptionsEditorWindow
1616
{
1717
protected override GUIContent WindowTitle { get { return new GUIContent ("Convert Options"); }}
18-
protected override float MinWindowHeight { get { return 300; } } // determined by trial and error
18+
protected override float MinWindowHeight { get { return 350; } } // determined by trial and error
1919
protected override string ExportButtonName { get { return "Convert"; } }
20-
private GameObject[] m_toConvert;
2120
private string m_prefabFileName = "";
2221

2322
private float m_prefabExtLabelWidth;
2423

24+
protected override bool DisableNameSelection {
25+
get {
26+
return (ToExport != null && ToExport.Length > 1);
27+
}
28+
}
29+
protected override bool DisableTransferAnim {
30+
get {
31+
return ToExport == null || ToExport.Length > 1;
32+
}
33+
}
34+
2535
public static void Init (IEnumerable<GameObject> toConvert)
2636
{
2737
ConvertToPrefabEditorWindow window = CreateWindow<ConvertToPrefabEditorWindow> ();
@@ -31,13 +41,24 @@ public static void Init (IEnumerable<GameObject> toConvert)
3141
}
3242

3343
protected void SetGameObjectsToConvert(IEnumerable<GameObject> toConvert){
34-
m_toConvert = toConvert.OrderBy (go => go.name).ToArray ();
44+
ToExport = toConvert.OrderBy (go => go.name).ToArray ();
3545

36-
if (m_toConvert.Length == 1) {
37-
m_prefabFileName = m_toConvert [0].name;
38-
} else if (m_toConvert.Length > 1) {
46+
TransferAnimationSource = null;
47+
TransferAnimationDest = null;
48+
49+
if (ToExport.Length == 1) {
50+
m_prefabFileName = ToExport [0].name;
51+
52+
// if only one object selected, set transfer source/dest to this object
53+
var go = ModelExporter.GetGameObject (ToExport [0]);
54+
if (go) {
55+
TransferAnimationSource = go.transform;
56+
TransferAnimationDest = go.transform;
57+
}
58+
} else if (ToExport.Length > 1) {
3959
m_prefabFileName = "(automatic)";
4060
}
61+
4162
this.SetFilename (m_prefabFileName);
4263
}
4364

@@ -63,28 +84,30 @@ protected override void Export ()
6384
return;
6485
}
6586

66-
if (m_toConvert == null) {
87+
if (ToExport == null) {
6788
Debug.LogError ("FbxExporter: missing object for conversion");
6889
return;
6990
}
7091

71-
if (m_toConvert.Length == 1) {
92+
if (ToExport.Length == 1) {
93+
var go = ModelExporter.GetGameObject (ToExport [0]);
7294
ConvertToModel.Convert (
73-
m_toConvert[0], fbxFullPath: fbxPath, prefabFullPath: prefabPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
95+
go, fbxFullPath: fbxPath, prefabFullPath: prefabPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
7496
);
7597
return;
7698
}
7799

78-
foreach (var go in m_toConvert) {
100+
foreach (var obj in ToExport) {
101+
var go = ModelExporter.GetGameObject (obj);
79102
ConvertToModel.Convert (
80103
go, fbxDirectoryFullPath: fbxDirPath, prefabDirectoryFullPath: prefabDirPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
81104
);
82105
}
83106
}
84107

85-
protected override bool DisableNameSelection ()
108+
protected override ExportOptionsSettingsSerializeBase SettingsObject
86109
{
87-
return m_toConvert.Length > 1;
110+
get { return ExportSettings.instance.convertToPrefabSettings.info; }
88111
}
89112
#if UNITY_2018_1_OR_NEWER
90113
protected override void ShowPresetReceiver ()
@@ -96,10 +119,10 @@ protected override void CreateCustomUI ()
96119
{
97120
GUILayout.BeginHorizontal ();
98121
EditorGUILayout.LabelField(new GUIContent(
99-
"Prefab Name:",
122+
"Prefab Name",
100123
"Filename to save prefab to."),GUILayout.Width(LabelWidth-TextFieldAlignOffset));
101124

102-
EditorGUI.BeginDisabledGroup (DisableNameSelection());
125+
EditorGUI.BeginDisabledGroup (DisableNameSelection);
103126
// Show the export name with an uneditable ".prefab" at the end
104127
//-------------------------------------
105128
EditorGUILayout.BeginVertical ();
@@ -121,7 +144,7 @@ protected override void CreateCustomUI ()
121144

122145
GUILayout.BeginHorizontal();
123146
EditorGUILayout.LabelField(new GUIContent(
124-
"Prefab Path:",
147+
"Prefab Path",
125148
"Relative path for saving Linked Prefabs."),GUILayout.Width(LabelWidth - FieldOffset));
126149

127150
var pathLabels = ExportSettings.GetRelativePrefabSavePaths();

Assets/FbxExporters/Editor/ConvertToPrefabSettings.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,10 @@ public override void OnInspectorGUI ()
5151
EditorGUI.EndDisabledGroup ();
5252
GUILayout.EndHorizontal();
5353

54-
// TODO: add implementation for these options, grey out in the meantime
55-
EditorGUI.BeginDisabledGroup (true);
56-
GUILayout.BeginHorizontal();
57-
EditorGUILayout.LabelField(new GUIContent("Transfer Root Motion To", "Select bone to transfer root motion animation to."), GUILayout.Width(LabelWidth - FieldOffset));
58-
EditorGUILayout.Popup(0, new string[]{"<None>"});
59-
GUILayout.EndHorizontal();
60-
EditorGUI.EndDisabledGroup ();
61-
6254
exportSettings.animatedSkinnedMesh = EditorGUILayout.Toggle ("Animated Skinned Mesh", exportSettings.animatedSkinnedMesh);
6355

6456
exportSettings.mayaCompatibleNaming = EditorGUILayout.Toggle (
65-
new GUIContent ("Compatible Naming:",
57+
new GUIContent ("Compatible Naming",
6658
"In Maya some symbols such as spaces and accents get replaced when importing an FBX " +
6759
"(e.g. \"foo bar\" becomes \"fooFBXASC032bar\"). " +
6860
"On export, convert the names of GameObjects so they are Maya compatible." +

0 commit comments

Comments
 (0)