Skip to content

Commit ec0e4b3

Browse files
committed
Merge branch 'master' into UNI-41963-check-filename-not-empty
2 parents b4f61bf + 99c2e0a commit ec0e4b3

File tree

9 files changed

+656
-141
lines changed

9 files changed

+656
-141
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

@@ -73,29 +94,31 @@ protected override bool Export ()
7394
return false;
7495
}
7596

76-
if (m_toConvert == null) {
97+
if (ToExport == null) {
7798
Debug.LogError ("FbxExporter: missing object for conversion");
7899
return false;
79100
}
80101

81-
if (m_toConvert.Length == 1) {
102+
if (ToExport.Length == 1) {
103+
var go = ModelExporter.GetGameObject (ToExport [0]);
82104
ConvertToModel.Convert (
83-
m_toConvert[0], fbxFullPath: fbxPath, prefabFullPath: prefabPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
105+
go, fbxFullPath: fbxPath, prefabFullPath: prefabPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
84106
);
85107
return true;
86108
}
87109

88-
foreach (var go in m_toConvert) {
110+
foreach (var obj in ToExport) {
111+
var go = ModelExporter.GetGameObject (obj);
89112
ConvertToModel.Convert (
90113
go, fbxDirectoryFullPath: fbxDirPath, prefabDirectoryFullPath: prefabDirPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
91114
);
92115
}
93116
return true;
94117
}
95118

96-
protected override bool DisableNameSelection ()
119+
protected override ExportOptionsSettingsSerializeBase SettingsObject
97120
{
98-
return m_toConvert.Length > 1;
121+
get { return ExportSettings.instance.convertToPrefabSettings.info; }
99122
}
100123
#if UNITY_2018_1_OR_NEWER
101124
protected override void ShowPresetReceiver ()
@@ -107,10 +130,10 @@ protected override void CreateCustomUI ()
107130
{
108131
GUILayout.BeginHorizontal ();
109132
EditorGUILayout.LabelField(new GUIContent(
110-
"Prefab Name:",
133+
"Prefab Name",
111134
"Filename to save prefab to."),GUILayout.Width(LabelWidth-TextFieldAlignOffset));
112135

113-
EditorGUI.BeginDisabledGroup (DisableNameSelection());
136+
EditorGUI.BeginDisabledGroup (DisableNameSelection);
114137
// Show the export name with an uneditable ".prefab" at the end
115138
//-------------------------------------
116139
EditorGUILayout.BeginVertical ();
@@ -132,7 +155,7 @@ protected override void CreateCustomUI ()
132155

133156
GUILayout.BeginHorizontal();
134157
EditorGUILayout.LabelField(new GUIContent(
135-
"Prefab Path:",
158+
"Prefab Path",
136159
"Relative path for saving Linked Prefabs."),GUILayout.Width(LabelWidth - FieldOffset));
137160

138161
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)