Skip to content

Commit d6eabb8

Browse files
committed
add preset selection button
+ flip position of export name and path + arrow to hide options + fix so export model save path doesn't get added twice
1 parent 15e2435 commit d6eabb8

File tree

2 files changed

+50
-38
lines changed

2 files changed

+50
-38
lines changed

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ public class ExportModelEditorWindow : EditorWindow
2121
private ModelExporter.AnimationExportType m_animExportType = ModelExporter.AnimationExportType.all;
2222

2323
private UnityEditor.Editor innerEditor;
24-
2524
private static FbxExportPresetSelectorReceiver receiver;
2625

26+
private static GUIContent presetIcon { get { return EditorGUIUtility.IconContent ("Preset.Context"); }}
27+
private static GUIStyle presetIconButton { get { return new GUIStyle("IconButton"); }}
28+
29+
private bool showOptions;
30+
31+
void OnEnable(){
32+
InitializeReceiver ();
33+
showOptions = true;
34+
}
35+
2736
public static void Init (string filename = "", ModelExporter.AnimationExportType exportType = ModelExporter.AnimationExportType.all)
2837
{
2938
ExportModelEditorWindow window = (ExportModelEditorWindow)EditorWindow.GetWindow <ExportModelEditorWindow>(WindowTitle, focus:true);
3039
window.SetFilename (filename);
3140
window.SetAnimationExportType (exportType);
3241
window.minSize = new Vector2 (SelectableLabelMinWidth + LabelWidth + BrowseButtonWidth, 100);
33-
34-
window.InitializeReceiver ();
35-
3642
window.Show ();
3743
}
3844

@@ -71,24 +77,47 @@ void OnGUI ()
7177
// Increasing the label width so that none of the text gets cut off
7278
EditorGUIUtility.labelWidth = LabelWidth;
7379

74-
EditorGUILayout.LabelField("Naming", EditorStyles.boldLabel);
80+
GUILayout.BeginHorizontal ();
81+
GUILayout.FlexibleSpace ();
82+
if(EditorGUILayout.DropdownButton(presetIcon, FocusType.Keyboard, presetIconButton)){
83+
InitializeReceiver ();
84+
receiver.SetTarget(ExportSettings.instance.exportModelSettings);
85+
receiver.SetInitialValue (new Preset (ExportSettings.instance.exportModelSettings));
86+
UnityEditor.Presets.PresetSelector.ShowSelector(ExportSettings.instance.exportModelSettings, null, true, receiver);
87+
}
88+
GUILayout.EndHorizontal();
89+
90+
EditorGUILayout.LabelField("Naming");
7591
EditorGUI.indentLevel++;
92+
93+
GUILayout.BeginHorizontal ();
94+
EditorGUILayout.LabelField(new GUIContent(
95+
"Export Name:",
96+
"Filename to save model to."),GUILayout.Width(LabelWidth - FieldOffset));
97+
98+
m_exportFileName = EditorGUILayout.TextField (m_exportFileName);
99+
if (!m_exportFileName.EndsWith (".fbx")) {
100+
m_exportFileName += ".fbx";
101+
}
102+
m_exportFileName = ModelExporter.ConvertToValidFilename(m_exportFileName);
103+
GUILayout.EndHorizontal ();
104+
76105
GUILayout.BeginHorizontal();
77106
EditorGUILayout.LabelField(new GUIContent(
78107
"Export Path:",
79108
"Relative path for saving Model Prefabs."),GUILayout.Width(LabelWidth - FieldOffset));
80109

81110
var pathLabels = ExportSettings.GetRelativeSavePaths();
82-
for(int i = 0; i < pathLabels.Length; i++){
111+
/*for(int i = 0; i < pathLabels.Length; i++){
83112
if (pathLabels[i] == ".") {
84113
pathLabels[i] = "(Assets root)";
85114
break; // no duplicate paths so safe to break
86115
}
87-
}
116+
}*/
88117

89118
ExportSettings.instance.selectedExportModelPath = EditorGUILayout.Popup (ExportSettings.instance.selectedExportModelPath, pathLabels, GUILayout.MinWidth(SelectableLabelMinWidth));
90119

91-
if (GUILayout.Button(new GUIContent("...", "Browse to a new location for saving model prefabs"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth)))
120+
if (GUILayout.Button(new GUIContent("...", "Browse to a new location to export to"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth)))
92121
{
93122
string initialPath = Application.dataPath;
94123

@@ -115,37 +144,22 @@ void OnGUI ()
115144
}
116145
}
117146
}
118-
119147
GUILayout.EndHorizontal();
120148

121-
GUILayout.BeginHorizontal ();
122-
EditorGUILayout.LabelField(new GUIContent(
123-
"Export Name:",
124-
"Filename to save model to."),GUILayout.Width(LabelWidth - FieldOffset));
125-
126-
m_exportFileName = EditorGUILayout.TextField (m_exportFileName);
127-
if (!m_exportFileName.EndsWith (".fbx")) {
128-
m_exportFileName += ".fbx";
129-
}
130-
m_exportFileName = ModelExporter.ConvertToValidFilename(m_exportFileName);
131-
GUILayout.EndHorizontal ();
132-
133-
if (!innerEditor) {
134-
var ms = ExportSettings.instance.exportModelSettings;
135-
if (!ms) {
136-
ExportSettings.LoadSettings ();
137-
ms = ExportSettings.instance.exportModelSettings;
149+
EditorGUILayout.Space ();
150+
EditorGUI.indentLevel--;
151+
showOptions = EditorGUILayout.Foldout (showOptions, "Options");
152+
EditorGUI.indentLevel++;
153+
if (showOptions) {
154+
if (!innerEditor) {
155+
var ms = ExportSettings.instance.exportModelSettings;
156+
if (!ms) {
157+
ExportSettings.LoadSettings ();
158+
ms = ExportSettings.instance.exportModelSettings;
159+
}
160+
innerEditor = UnityEditor.Editor.CreateEditor (ms, editorType: typeof(ExportModelSettingsEditor));
138161
}
139-
innerEditor = UnityEditor.Editor.CreateEditor (ms, editorType: typeof(ExportModelSettingsEditor));
140-
}
141-
//innerEditor.DrawHeader ();
142-
innerEditor.OnInspectorGUI ();
143-
144-
if (GUILayout.Button ("select preset")) {
145-
InitializeReceiver ();
146-
receiver.SetTarget(ExportSettings.instance.exportModelSettings);
147-
receiver.SetInitialValue (new Preset (ExportSettings.instance.exportModelSettings));
148-
UnityEditor.Presets.PresetSelector.ShowSelector(ExportSettings.instance.exportModelSettings, null, true, receiver);
162+
innerEditor.OnInspectorGUI ();
149163
}
150164

151165
GUILayout.FlexibleSpace ();
@@ -158,7 +172,6 @@ void OnGUI ()
158172

159173
if (GUILayout.Button ("Export")) {
160174
var filePath = ExportSettings.GetExportModelAbsoluteSavePath ();
161-
ExportSettings.AddExportModelSavePath(filePath);
162175

163176
filePath = System.IO.Path.Combine (filePath, m_exportFileName);
164177

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,6 @@ public static string[] GetRelativeSavePaths(){
10041004
}
10051005

10061006
public static void AddExportModelSavePath(string savePath){
1007-
savePath = ConvertToAssetRelativePath (savePath);
10081007
var exportSavePaths = instance.exportModelSavePaths;
10091008
if (exportSavePaths.Contains (savePath)) {
10101009
// move to first place if it isn't already

0 commit comments

Comments
 (0)