@@ -10,9 +10,11 @@ namespace FbxExporters.EditorTools {
10
10
[ CustomEditor ( typeof ( ExportSettings ) ) ]
11
11
public class ExportSettingsEditor : UnityEditor . Editor {
12
12
Vector2 scrollPos = Vector2 . zero ;
13
- const float LabelWidth = 130 ;
13
+ const float LabelWidth = 144 ;
14
14
const float SelectableLabelMinWidth = 90 ;
15
15
const float BrowseButtonWidth = 25 ;
16
+ const float FieldOffset = 18 ;
17
+ const float BrowseButtonOffset = 5 ;
16
18
17
19
public override void OnInspectorGUI ( ) {
18
20
ExportSettings exportSettings = ( ExportSettings ) target ;
@@ -27,6 +29,8 @@ public override void OnInspectorGUI() {
27
29
GUILayout . Label ( "Version: " + version , EditorStyles . centeredGreyMiniLabel ) ;
28
30
EditorGUILayout . Space ( ) ;
29
31
}
32
+ EditorGUILayout . LabelField ( "Export Options" , EditorStyles . boldLabel ) ;
33
+ EditorGUI . indentLevel ++ ;
30
34
GUILayout . BeginVertical ( ) ;
31
35
exportSettings . mayaCompatibleNames = EditorGUILayout . Toggle (
32
36
new GUIContent ( "Compatible Naming:" ,
@@ -45,47 +49,53 @@ public override void OnInspectorGUI() {
45
49
exportSettings . centerObjects
46
50
) ;
47
51
48
- EditorGUILayout . Space ( ) ;
49
-
50
52
GUILayout . BeginHorizontal ( ) ;
51
- GUILayout . Label ( new GUIContent ( "Export Format:" , "Export the FBX file in the standard binary format." +
52
- " Select ASCII to export the FBX file in ASCII format." ) , GUILayout . Width ( LabelWidth - 3 ) ) ;
53
+ EditorGUILayout . LabelField ( new GUIContent ( "Export Format:" , "Export the FBX file in the standard binary format." +
54
+ " Select ASCII to export the FBX file in ASCII format." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
53
55
exportSettings . ExportFormatSelection = EditorGUILayout . Popup ( exportSettings . ExportFormatSelection , new string [ ] { "Binary" , "ASCII" } ) ;
54
56
GUILayout . EndHorizontal ( ) ;
55
57
56
- EditorGUILayout . Space ( ) ;
57
-
58
- GUILayout . BeginHorizontal ( ) ;
59
- GUILayout . Label ( new GUIContent (
58
+ GUILayout . BeginHorizontal ( ) ;
59
+ EditorGUILayout . LabelField ( new GUIContent (
60
60
"Export Path:" ,
61
- "Relative path for saving Model Prefabs." ) , GUILayout . Width ( LabelWidth - 3 ) ) ;
61
+ "Relative path for saving Model Prefabs." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
62
62
63
63
var pathLabel = ExportSettings . GetRelativeSavePath ( ) ;
64
64
if ( pathLabel == "." ) { pathLabel = "(Assets root)" ; }
65
65
EditorGUILayout . SelectableLabel ( pathLabel ,
66
66
EditorStyles . textField ,
67
67
GUILayout . MinWidth ( SelectableLabelMinWidth ) ,
68
68
GUILayout . Height ( EditorGUIUtility . singleLineHeight ) ) ;
69
+ GUILayout . EndHorizontal ( ) ;
70
+ GUILayout . BeginHorizontal ( ) ;
71
+
72
+ GUILayout . Space ( LabelWidth + BrowseButtonOffset ) ;
69
73
70
- if ( GUILayout . Button ( new GUIContent ( "..." , "Browse to a new location for saving model prefabs" ) , EditorStyles . miniButton , GUILayout . Width ( BrowseButtonWidth ) ) ) {
74
+ if ( GUILayout . Button ( new GUIContent ( "..." , "Browse to a new location for saving model prefabs" ) , EditorStyles . miniButton , GUILayout . Width ( BrowseButtonWidth ) ) )
75
+ {
71
76
string initialPath = ExportSettings . GetAbsoluteSavePath ( ) ;
72
77
73
78
// if the directory doesn't exist, set it to the default save path
74
79
// so we don't open somewhere unexpected
75
- if ( ! System . IO . Directory . Exists ( initialPath ) ) {
80
+ if ( ! System . IO . Directory . Exists ( initialPath ) )
81
+ {
76
82
initialPath = Application . dataPath ;
77
83
}
78
84
79
- string fullPath = EditorUtility . OpenFolderPanel (
85
+ string fullPath = EditorUtility . OpenFolderPanel (
80
86
"Select Model Prefabs Path" , initialPath , null
81
87
) ;
82
88
83
89
// Unless the user canceled, make sure they chose something in the Assets folder.
84
- if ( ! string . IsNullOrEmpty ( fullPath ) ) {
90
+ if ( ! string . IsNullOrEmpty ( fullPath ) )
91
+ {
85
92
var relativePath = ExportSettings . ConvertToAssetRelativePath ( fullPath ) ;
86
- if ( string . IsNullOrEmpty ( relativePath ) ) {
87
- Debug . LogWarning ( "Please select a location in the Assets folder" ) ;
88
- } else {
93
+ if ( string . IsNullOrEmpty ( relativePath ) )
94
+ {
95
+ Debug . LogWarning ( "Please select a location in the Assets folder" ) ;
96
+ }
97
+ else
98
+ {
89
99
ExportSettings . SetRelativeSavePath ( relativePath ) ;
90
100
91
101
// Make sure focus is removed from the selectable label
@@ -95,18 +105,28 @@ public override void OnInspectorGUI() {
95
105
}
96
106
}
97
107
}
98
- GUILayout . EndHorizontal ( ) ;
108
+ GUILayout . EndHorizontal ( ) ;
109
+
110
+ EditorGUILayout . Space ( ) ;
111
+ EditorGUILayout . Space ( ) ;
112
+ EditorGUI . indentLevel -- ;
113
+ EditorGUILayout . LabelField ( "Integration" , EditorStyles . boldLabel ) ;
114
+ EditorGUI . indentLevel ++ ;
99
115
100
116
GUILayout . BeginHorizontal ( ) ;
101
- GUILayout . Label ( new GUIContent (
117
+ EditorGUILayout . LabelField ( new GUIContent (
102
118
"Integrations Path:" ,
103
- "Installation path for 3D application integrations." ) , GUILayout . Width ( LabelWidth - 3 ) ) ;
119
+ "Installation path for 3D application integrations." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
104
120
105
121
var IntegrationsPathLabel = ExportSettings . GetIntegrationSavePath ( ) ;
106
122
EditorGUILayout . SelectableLabel ( IntegrationsPathLabel ,
107
123
EditorStyles . textField ,
108
124
GUILayout . MinWidth ( SelectableLabelMinWidth ) ,
109
125
GUILayout . Height ( EditorGUIUtility . singleLineHeight ) ) ;
126
+ GUILayout . EndHorizontal ( ) ;
127
+ GUILayout . BeginHorizontal ( ) ;
128
+
129
+ GUILayout . Space ( LabelWidth + BrowseButtonOffset ) ;
110
130
111
131
if ( GUILayout . Button ( new GUIContent ( "..." , "Browse to a new installation path for 3D application integrations" ) , EditorStyles . miniButton , GUILayout . Width ( BrowseButtonWidth ) ) )
112
132
{
@@ -129,17 +149,21 @@ public override void OnInspectorGUI() {
129
149
130
150
GUILayout . EndHorizontal ( ) ;
131
151
132
- EditorGUILayout . Space ( ) ;
133
-
134
152
GUILayout . BeginHorizontal ( ) ;
135
- GUILayout . Label ( new GUIContent (
153
+ EditorGUILayout . LabelField ( new GUIContent (
136
154
"3D Application:" ,
137
- "Select the 3D Application for which you would like to install the Unity integration." ) , GUILayout . Width ( LabelWidth - 3 ) ) ;
155
+ "Select the 3D Application for which you would like to install the Unity integration." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
138
156
139
157
// dropdown to select Maya version to use
140
158
var options = ExportSettings . GetDCCOptions ( ) ;
141
159
142
160
exportSettings . selectedDCCApp = EditorGUILayout . Popup ( exportSettings . selectedDCCApp , options ) ;
161
+
162
+ GUILayout . EndHorizontal ( ) ;
163
+ GUILayout . BeginHorizontal ( ) ;
164
+
165
+ GUILayout . Space ( LabelWidth + BrowseButtonOffset ) ;
166
+
143
167
if ( GUILayout . Button ( new GUIContent ( "..." , "Browse to a 3D application in a non-default location" ) , EditorStyles . miniButton , GUILayout . Width ( BrowseButtonWidth ) ) ) {
144
168
var ext = "" ;
145
169
switch ( Application . platform ) {
@@ -176,19 +200,28 @@ public override void OnInspectorGUI() {
176
200
177
201
EditorGUILayout . Space ( ) ;
178
202
203
+ exportSettings . launchAfterInstallation = EditorGUILayout . Toggle (
204
+ new GUIContent ( "Keep open:" ,
205
+ "Keep the selected 3D application open after Unity integration install has completed." ) ,
206
+ exportSettings . launchAfterInstallation
207
+ ) ;
208
+
209
+ exportSettings . HideSendToUnityMenu = EditorGUILayout . Toggle (
210
+ new GUIContent ( "Hide native menu:" ,
211
+ "Replace Maya's native 'Send to Unity' menu with the Unity Integration's menu" ) ,
212
+ exportSettings . HideSendToUnityMenu
213
+ ) ;
214
+
215
+ EditorGUILayout . Space ( ) ;
216
+
217
+
179
218
var installIntegrationContent = new GUIContent (
180
219
"Install Unity Integration" ,
181
220
"Install and configure the Unity integration for the selected 3D application so that you can import and export directly with this project." ) ;
182
221
if ( GUILayout . Button ( installIntegrationContent ) ) {
183
222
FbxExporters . Editor . IntegrationsUI . InstallDCCIntegration ( ) ;
184
223
}
185
224
186
- exportSettings . launchAfterInstallation = EditorGUILayout . Toggle (
187
- new GUIContent ( "Keep 3D Application opened:" ,
188
- "Keep the selected 3D application open after Unity integration install has completed." ) ,
189
- exportSettings . launchAfterInstallation
190
- ) ;
191
-
192
225
GUILayout . FlexibleSpace ( ) ;
193
226
GUILayout . EndScrollView ( ) ;
194
227
GUILayout . EndVertical ( ) ;
@@ -300,6 +333,7 @@ public static string[] DCCVendorLocations {
300
333
public bool mayaCompatibleNames ;
301
334
public bool centerObjects ;
302
335
public bool launchAfterInstallation ;
336
+ public bool HideSendToUnityMenu ;
303
337
public int ExportFormatSelection ;
304
338
305
339
public string IntegrationSavePath ;
@@ -331,6 +365,7 @@ protected override void LoadDefaults()
331
365
mayaCompatibleNames = true ;
332
366
centerObjects = true ;
333
367
launchAfterInstallation = true ;
368
+ HideSendToUnityMenu = true ;
334
369
ExportFormatSelection = 0 ;
335
370
convertToModelSavePath = kDefaultSavePath ;
336
371
IntegrationSavePath = DefaultIntegrationSavePath ;
@@ -601,15 +636,15 @@ public static GUIContent[] GetDCCOptions(){
601
636
FindDCCInstalls ( ) ;
602
637
}
603
638
639
+ // store the selected app
640
+ var prevSelection = instance . dccOptionPaths [ instance . selectedDCCApp ] ;
641
+
604
642
// remove options that no longer exist
605
643
List < string > pathsToDelete = new List < string > ( ) ;
606
644
List < string > namesToDelete = new List < string > ( ) ;
607
645
for ( int i = 0 ; i < instance . dccOptionPaths . Count ; i ++ ) {
608
646
var dccPath = instance . dccOptionPaths [ i ] ;
609
647
if ( ! File . Exists ( dccPath ) ) {
610
- if ( i == instance . selectedDCCApp ) {
611
- instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
612
- }
613
648
namesToDelete . Add ( instance . dccOptionNames [ i ] ) ;
614
649
pathsToDelete . Add ( dccPath ) ;
615
650
}
@@ -621,6 +656,13 @@ public static GUIContent[] GetDCCOptions(){
621
656
instance . dccOptionNames . Remove ( str ) ;
622
657
}
623
658
659
+ // set the selected DCC app to the previous selection
660
+ instance . selectedDCCApp = instance . dccOptionPaths . IndexOf ( prevSelection ) ;
661
+ if ( instance . selectedDCCApp < 0 ) {
662
+ // find preferred app if previous selection no longer exists
663
+ instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
664
+ }
665
+
624
666
if ( instance . dccOptionPaths . Count <= 0 ) {
625
667
instance . selectedDCCApp = 0 ;
626
668
return new GUIContent [ ] {
@@ -635,7 +677,6 @@ public static GUIContent[] GetDCCOptions(){
635
677
instance . dccOptionPaths [ i ]
636
678
) ;
637
679
}
638
-
639
680
return optionArray ;
640
681
}
641
682
@@ -762,7 +803,8 @@ public static void SetRelativeSavePath(string newPath) {
762
803
public static string GetIntegrationSavePath ( )
763
804
{
764
805
//If the save path gets messed up and ends up not being valid, just use the project folder as the default
765
- if ( string . IsNullOrEmpty ( instance . IntegrationSavePath . Trim ( ) ) || ! Directory . Exists ( instance . IntegrationSavePath ) )
806
+ if ( string . IsNullOrEmpty ( instance . IntegrationSavePath ) ||
807
+ ! Directory . Exists ( instance . IntegrationSavePath ) )
766
808
{
767
809
//The project folder, above the asset folder
768
810
instance . IntegrationSavePath = DefaultIntegrationSavePath ;
0 commit comments