@@ -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,19 +105,29 @@ public override void OnInspectorGUI() {
95
105
}
96
106
}
97
107
}
98
- GUILayout . EndHorizontal ( ) ;
108
+ GUILayout . EndHorizontal ( ) ;
99
109
100
- EditorGUILayout . Space ( ) ;
110
+ EditorGUILayout . Space ( ) ;
111
+ EditorGUILayout . Space ( ) ;
112
+ EditorGUI . indentLevel -- ;
113
+ EditorGUILayout . LabelField ( "Integration" , EditorStyles . boldLabel ) ;
114
+ EditorGUI . indentLevel ++ ;
101
115
102
116
GUILayout . BeginHorizontal ( ) ;
103
- GUILayout . Label ( new GUIContent (
117
+ EditorGUILayout . LabelField ( new GUIContent (
104
118
"3D Application:" ,
105
- "Select the 3D Application for which you would like to install the Unity integration." ) , GUILayout . Width ( LabelWidth - 3 ) ) ;
119
+ "Select the 3D Application for which you would like to install the Unity integration." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
106
120
107
121
// dropdown to select Maya version to use
108
122
var options = ExportSettings . GetDCCOptions ( ) ;
109
123
110
124
exportSettings . selectedDCCApp = EditorGUILayout . Popup ( exportSettings . selectedDCCApp , options ) ;
125
+
126
+ GUILayout . EndHorizontal ( ) ;
127
+ GUILayout . BeginHorizontal ( ) ;
128
+
129
+ GUILayout . Space ( LabelWidth + BrowseButtonOffset ) ;
130
+
111
131
if ( GUILayout . Button ( new GUIContent ( "..." , "Browse to a 3D application in a non-default location" ) , EditorStyles . miniButton , GUILayout . Width ( BrowseButtonWidth ) ) ) {
112
132
var ext = "" ;
113
133
switch ( Application . platform ) {
@@ -144,19 +164,28 @@ public override void OnInspectorGUI() {
144
164
145
165
EditorGUILayout . Space ( ) ;
146
166
167
+ exportSettings . launchAfterInstallation = EditorGUILayout . Toggle (
168
+ new GUIContent ( "Keep open:" ,
169
+ "Keep the selected 3D application open after Unity integration install has completed." ) ,
170
+ exportSettings . launchAfterInstallation
171
+ ) ;
172
+
173
+ exportSettings . HideSendToUnityMenu = EditorGUILayout . Toggle (
174
+ new GUIContent ( "Hide native menu:" ,
175
+ "Replace Maya's native 'Send to Unity' menu with the Unity Integration's menu" ) ,
176
+ exportSettings . HideSendToUnityMenu
177
+ ) ;
178
+
179
+ EditorGUILayout . Space ( ) ;
180
+
181
+
147
182
var installIntegrationContent = new GUIContent (
148
183
"Install Unity Integration" ,
149
184
"Install and configure the Unity integration for the selected 3D application so that you can import and export directly with this project." ) ;
150
185
if ( GUILayout . Button ( installIntegrationContent ) ) {
151
186
FbxExporters . Editor . IntegrationsUI . InstallDCCIntegration ( ) ;
152
187
}
153
188
154
- exportSettings . launchAfterInstallation = EditorGUILayout . Toggle (
155
- new GUIContent ( "Keep 3D Application opened:" ,
156
- "Keep the selected 3D application open after Unity integration install has completed." ) ,
157
- exportSettings . launchAfterInstallation
158
- ) ;
159
-
160
189
GUILayout . FlexibleSpace ( ) ;
161
190
GUILayout . EndScrollView ( ) ;
162
191
GUILayout . EndVertical ( ) ;
@@ -268,6 +297,7 @@ public static string[] DCCVendorLocations {
268
297
public bool mayaCompatibleNames ;
269
298
public bool centerObjects ;
270
299
public bool launchAfterInstallation ;
300
+ public bool HideSendToUnityMenu ;
271
301
public int ExportFormatSelection ;
272
302
273
303
public string IntegrationSavePath ;
@@ -299,6 +329,7 @@ protected override void LoadDefaults()
299
329
mayaCompatibleNames = true ;
300
330
centerObjects = true ;
301
331
launchAfterInstallation = true ;
332
+ HideSendToUnityMenu = true ;
302
333
ExportFormatSelection = 0 ;
303
334
convertToModelSavePath = kDefaultSavePath ;
304
335
IntegrationSavePath = DefaultIntegrationSavePath ;
@@ -569,15 +600,15 @@ public static GUIContent[] GetDCCOptions(){
569
600
FindDCCInstalls ( ) ;
570
601
}
571
602
603
+ // store the selected app
604
+ var prevSelection = instance . dccOptionPaths [ instance . selectedDCCApp ] ;
605
+
572
606
// remove options that no longer exist
573
607
List < string > pathsToDelete = new List < string > ( ) ;
574
608
List < string > namesToDelete = new List < string > ( ) ;
575
609
for ( int i = 0 ; i < instance . dccOptionPaths . Count ; i ++ ) {
576
610
var dccPath = instance . dccOptionPaths [ i ] ;
577
611
if ( ! File . Exists ( dccPath ) ) {
578
- if ( i == instance . selectedDCCApp ) {
579
- instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
580
- }
581
612
namesToDelete . Add ( instance . dccOptionNames [ i ] ) ;
582
613
pathsToDelete . Add ( dccPath ) ;
583
614
}
@@ -589,6 +620,13 @@ public static GUIContent[] GetDCCOptions(){
589
620
instance . dccOptionNames . Remove ( str ) ;
590
621
}
591
622
623
+ // set the selected DCC app to the previous selection
624
+ instance . selectedDCCApp = instance . dccOptionPaths . IndexOf ( prevSelection ) ;
625
+ if ( instance . selectedDCCApp < 0 ) {
626
+ // find preferred app if previous selection no longer exists
627
+ instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
628
+ }
629
+
592
630
if ( instance . dccOptionPaths . Count <= 0 ) {
593
631
instance . selectedDCCApp = 0 ;
594
632
return new GUIContent [ ] {
@@ -603,7 +641,6 @@ public static GUIContent[] GetDCCOptions(){
603
641
instance . dccOptionPaths [ i ]
604
642
) ;
605
643
}
606
-
607
644
return optionArray ;
608
645
}
609
646
@@ -730,7 +767,8 @@ public static void SetRelativeSavePath(string newPath) {
730
767
public static string GetIntegrationSavePath ( )
731
768
{
732
769
//If the save path gets messed up and ends up not being valid, just use the project folder as the default
733
- if ( string . IsNullOrEmpty ( instance . IntegrationSavePath . Trim ( ) ) || ! Directory . Exists ( instance . IntegrationSavePath ) )
770
+ if ( string . IsNullOrEmpty ( instance . IntegrationSavePath ) ||
771
+ ! Directory . Exists ( instance . IntegrationSavePath ) )
734
772
{
735
773
//The project folder, above the asset folder
736
774
instance . IntegrationSavePath = DefaultIntegrationSavePath ;
0 commit comments