3
3
using UnityEngine ;
4
4
using UnityEditor ;
5
5
using FbxExporters . EditorTools ;
6
+ using UnityEditor . Presets ;
6
7
7
8
namespace FbxExporters
8
9
{
@@ -21,15 +22,30 @@ public class ExportModelEditorWindow : EditorWindow
21
22
22
23
private UnityEditor . Editor innerEditor ;
23
24
25
+ private static FbxExportPresetSelectorReceiver receiver ;
26
+
24
27
public static void Init ( string filename = "" , ModelExporter . AnimationExportType exportType = ModelExporter . AnimationExportType . all )
25
28
{
26
29
ExportModelEditorWindow window = ( ExportModelEditorWindow ) EditorWindow . GetWindow < ExportModelEditorWindow > ( WindowTitle , focus : true ) ;
27
30
window . SetFilename ( filename ) ;
28
31
window . SetAnimationExportType ( exportType ) ;
29
32
window . minSize = new Vector2 ( SelectableLabelMinWidth + LabelWidth + BrowseButtonWidth , 100 ) ;
33
+
34
+ window . InitializeReceiver ( ) ;
35
+
30
36
window . Show ( ) ;
31
37
}
32
38
39
+ private void InitializeReceiver ( ) {
40
+ if ( ! receiver ) {
41
+ receiver = ScriptableObject . CreateInstance < FbxExportPresetSelectorReceiver > ( ) as FbxExportPresetSelectorReceiver ;
42
+ receiver . SelectionChanged -= OnPresetSelectionChanged ;
43
+ receiver . SelectionChanged += OnPresetSelectionChanged ;
44
+ receiver . DialogClosed -= OnPresetDialogClosed ;
45
+ receiver . DialogClosed += OnPresetDialogClosed ;
46
+ }
47
+ }
48
+
33
49
public void SetFilename ( string filename ) {
34
50
m_exportFileName = filename ;
35
51
}
@@ -38,6 +54,18 @@ public void SetAnimationExportType(ModelExporter.AnimationExportType exportType)
38
54
m_animExportType = exportType ;
39
55
}
40
56
57
+ public void OnPresetDialogClosed ( )
58
+ {
59
+ // save once preset selection is finished
60
+ EditorUtility . SetDirty ( ExportSettings . instance ) ;
61
+ ExportSettings . instance . Save ( ) ;
62
+ }
63
+
64
+ public void OnPresetSelectionChanged ( )
65
+ {
66
+ this . Repaint ( ) ;
67
+ }
68
+
41
69
void OnGUI ( )
42
70
{
43
71
// Increasing the label width so that none of the text gets cut off
@@ -110,9 +138,16 @@ void OnGUI ()
110
138
}
111
139
innerEditor = UnityEditor . Editor . CreateEditor ( ms , editorType : typeof ( ExportModelSettingsEditor ) ) ;
112
140
}
113
- innerEditor . DrawHeader ( ) ;
141
+ // innerEditor.DrawHeader ();
114
142
innerEditor . OnInspectorGUI ( ) ;
115
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 ) ;
149
+ }
150
+
116
151
GUILayout . FlexibleSpace ( ) ;
117
152
118
153
GUILayout . BeginHorizontal ( ) ;
0 commit comments