@@ -16,13 +16,24 @@ public class ExportModelEditorWindow : EditorWindow
16
16
private const float BrowseButtonWidth = 25 ;
17
17
private const float LabelWidth = 144 ;
18
18
private const float FieldOffset = 18 ;
19
+ private string m_exportFileName = "" ;
20
+ private ModelExporter . AnimationExportType m_animExportType = ModelExporter . AnimationExportType . all ;
19
21
20
- public static void Init ( )
22
+ public static void Init ( string filename = "" , ModelExporter . AnimationExportType exportType = ModelExporter . AnimationExportType . all )
21
23
{
22
24
ExportModelEditorWindow window = ( ExportModelEditorWindow ) EditorWindow . GetWindow < ExportModelEditorWindow > ( WindowTitle , focus : true ) ;
25
+ window . SetFilename ( filename ) ;
26
+ window . SetAnimationExportType ( exportType ) ;
27
+ window . minSize = new Vector2 ( SelectableLabelMinWidth + LabelWidth + BrowseButtonWidth , 100 ) ;
23
28
window . Show ( ) ;
29
+ }
24
30
25
- window . minSize = new Vector2 ( SelectableLabelMinWidth + LabelWidth + BrowseButtonWidth , 100 ) ;
31
+ public void SetFilename ( string filename ) {
32
+ m_exportFileName = filename ;
33
+ }
34
+
35
+ public void SetAnimationExportType ( ModelExporter . AnimationExportType exportType ) {
36
+ m_animExportType = exportType ;
26
37
}
27
38
28
39
void OnGUI ( )
@@ -80,6 +91,40 @@ void OnGUI ()
80
91
}
81
92
82
93
GUILayout . EndHorizontal ( ) ;
94
+
95
+ GUILayout . BeginHorizontal ( ) ;
96
+ EditorGUILayout . LabelField ( new GUIContent (
97
+ "Export Name:" ,
98
+ "Filename to save model to." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
99
+
100
+ m_exportFileName = EditorGUILayout . TextField ( m_exportFileName ) ;
101
+ if ( ! m_exportFileName . EndsWith ( ".fbx" ) ) {
102
+ m_exportFileName += ".fbx" ;
103
+ }
104
+ m_exportFileName = ModelExporter . ConvertToValidFilename ( m_exportFileName ) ;
105
+ GUILayout . EndHorizontal ( ) ;
106
+
107
+ GUILayout . FlexibleSpace ( ) ;
108
+
109
+ GUILayout . BeginHorizontal ( ) ;
110
+ GUILayout . FlexibleSpace ( ) ;
111
+ if ( GUILayout . Button ( "Cancel" ) ) {
112
+ this . Close ( ) ;
113
+ }
114
+
115
+ if ( GUILayout . Button ( "Export" ) ) {
116
+ var filePath = ExportSettings . GetAbsoluteSavePath ( ) ;
117
+ filePath = System . IO . Path . Combine ( filePath , m_exportFileName ) ;
118
+
119
+ //TODO: check if file already exists, give a warning if it does
120
+ if ( ModelExporter . ExportObjects ( filePath , exportType : m_animExportType , lodExportType : ExportSettings . instance . lodExportType ) != null ) {
121
+ // refresh the asset database so that the file appears in the
122
+ // asset folder view.
123
+ AssetDatabase . Refresh ( ) ;
124
+ }
125
+ this . Close ( ) ;
126
+ }
127
+ GUILayout . EndHorizontal ( ) ;
83
128
}
84
129
}
85
130
}
0 commit comments