@@ -21,18 +21,24 @@ public class ExportModelEditorWindow : EditorWindow
21
21
private ModelExporter . AnimationExportType m_animExportType = ModelExporter . AnimationExportType . all ;
22
22
23
23
private UnityEditor . Editor innerEditor ;
24
-
25
24
private static FbxExportPresetSelectorReceiver receiver ;
26
25
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
+
27
36
public static void Init ( string filename = "" , ModelExporter . AnimationExportType exportType = ModelExporter . AnimationExportType . all )
28
37
{
29
38
ExportModelEditorWindow window = ( ExportModelEditorWindow ) EditorWindow . GetWindow < ExportModelEditorWindow > ( WindowTitle , focus : true ) ;
30
39
window . SetFilename ( filename ) ;
31
40
window . SetAnimationExportType ( exportType ) ;
32
41
window . minSize = new Vector2 ( SelectableLabelMinWidth + LabelWidth + BrowseButtonWidth , 100 ) ;
33
-
34
- window . InitializeReceiver ( ) ;
35
-
36
42
window . Show ( ) ;
37
43
}
38
44
@@ -71,24 +77,47 @@ void OnGUI ()
71
77
// Increasing the label width so that none of the text gets cut off
72
78
EditorGUIUtility . labelWidth = LabelWidth ;
73
79
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" ) ;
75
91
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
+
76
105
GUILayout . BeginHorizontal ( ) ;
77
106
EditorGUILayout . LabelField ( new GUIContent (
78
107
"Export Path:" ,
79
108
"Relative path for saving Model Prefabs." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
80
109
81
110
var pathLabels = ExportSettings . GetRelativeSavePaths ( ) ;
82
- for ( int i = 0 ; i < pathLabels . Length ; i ++ ) {
111
+ /* for(int i = 0; i < pathLabels.Length; i++){
83
112
if (pathLabels[i] == ".") {
84
113
pathLabels[i] = "(Assets root)";
85
114
break; // no duplicate paths so safe to break
86
115
}
87
- }
116
+ }*/
88
117
89
118
ExportSettings . instance . selectedExportModelPath = EditorGUILayout . Popup ( ExportSettings . instance . selectedExportModelPath , pathLabels , GUILayout . MinWidth ( SelectableLabelMinWidth ) ) ;
90
119
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 ) ) )
92
121
{
93
122
string initialPath = Application . dataPath ;
94
123
@@ -115,37 +144,22 @@ void OnGUI ()
115
144
}
116
145
}
117
146
}
118
-
119
147
GUILayout . EndHorizontal ( ) ;
120
148
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 ) ) ;
138
161
}
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 ( ) ;
149
163
}
150
164
151
165
GUILayout . FlexibleSpace ( ) ;
@@ -158,7 +172,6 @@ void OnGUI ()
158
172
159
173
if ( GUILayout . Button ( "Export" ) ) {
160
174
var filePath = ExportSettings . GetExportModelAbsoluteSavePath ( ) ;
161
- ExportSettings . AddExportModelSavePath ( filePath ) ;
162
175
163
176
filePath = System . IO . Path . Combine ( filePath , m_exportFileName ) ;
164
177
0 commit comments