@@ -114,39 +114,35 @@ public override void OnInspectorGUI() {
114
114
int oldValue = exportSettings . selectedDCCApp ;
115
115
exportSettings . selectedDCCApp = EditorGUILayout . Popup ( exportSettings . selectedDCCApp , options ) ;
116
116
if ( exportSettings . selectedDCCApp == options . Length - 1 ) {
117
- var ext = "exe" ;
118
- #if UNITY_EDITOR_OSX
119
- ext = "app" ;
120
- #endif
117
+ var ext = "" ;
118
+ switch ( Application . platform ) {
119
+ case RuntimePlatform . WindowsEditor :
120
+ ext = "exe" ;
121
+ break ;
122
+ case RuntimePlatform . OSXEditor :
123
+ ext = "app" ;
124
+ break ;
125
+ default :
126
+ throw new System . NotImplementedException ( ) ;
127
+ }
128
+
121
129
string dccPath = EditorUtility . OpenFilePanel ( "Select DCC Application" , ExportSettings . kDefaultAdskRoot , ext ) ;
122
130
123
131
// check that the path is valid and references the maya executable
124
132
if ( ! string . IsNullOrEmpty ( dccPath ) ) {
125
- if ( ! Path . GetFileNameWithoutExtension ( dccPath ) . ToLower ( ) . Equals ( "maya" ) ) {
126
- // clicked on the wrong application, try to see if we can still find
127
- // maya in this directory.
128
- var mayaDir = new DirectoryInfo ( Path . GetDirectoryName ( dccPath ) ) ;
129
- #if UNITY_EDITOR_OSX
130
- var files = mayaDir . GetDirectories ( "*." + ext ) ;
131
- #else
132
- var files = mayaDir . GetFiles ( "*." + ext ) ;
133
- #endif
134
- bool foundMaya = false ;
135
- foreach ( var file in files ) {
136
- var filename = Path . GetFileNameWithoutExtension ( file . Name ) . ToLower ( ) ;
137
- if ( filename . Equals ( "maya" ) ) {
138
- dccPath = file . FullName . Replace ( "\\ " , "/" ) ;
139
- foundMaya = true ;
140
- break ;
141
- }
142
- }
143
- if ( ! foundMaya ) {
144
- Debug . LogError ( string . Format ( "Could not find Maya at: \" {0}\" " , mayaDir . FullName ) ) ;
145
- exportSettings . selectedDCCApp = oldValue ;
146
- return ;
147
- }
133
+ bool foundMax = false ;
134
+ var foundDCCPath = TryFindDCC ( dccPath , ext , ExportSettings . DCCType . Maya ) ;
135
+ if ( foundDCCPath == null && Application . platform == RuntimePlatform . WindowsEditor ) {
136
+ foundDCCPath = TryFindDCC ( dccPath , ext , ExportSettings . DCCType . Max ) ;
137
+ foundMax = true ;
138
+ }
139
+ if ( foundDCCPath == null ) {
140
+ Debug . LogError ( string . Format ( "Could not find supported DCC application at: \" {0}\" " , Path . GetDirectoryName ( dccPath ) ) ) ;
141
+ exportSettings . selectedDCCApp = oldValue ;
142
+ } else {
143
+ dccPath = foundDCCPath ;
144
+ ExportSettings . AddDCCOption ( dccPath , foundMax ? ExportSettings . DCCType . Max : ExportSettings . DCCType . Maya ) ;
148
145
}
149
- ExportSettings . AddDCCOption ( dccPath , ExportSettings . DCCType . Maya ) ;
150
146
Repaint ( ) ;
151
147
} else {
152
148
exportSettings . selectedDCCApp = oldValue ;
@@ -156,13 +152,9 @@ public override void OnInspectorGUI() {
156
152
157
153
var installIntegrationContent = new GUIContent (
158
154
"Install Unity Integration" ,
159
- "Install and configure the Unity integration for Maya so that you can import and export directly to this project." ) ;
155
+ "Install and configure the Unity integration for the selected DCC so that you can import and export directly to this project." ) ;
160
156
if ( GUILayout . Button ( installIntegrationContent ) ) {
161
- FbxExporters . Editor . IntegrationsUI . InstallMayaIntegration ( ) ;
162
- }
163
-
164
- if ( GUILayout . Button ( "Install 3DS Max Integration" ) ) {
165
- FbxExporters . Editor . IntegrationsUI . InstallMaxIntegration ( ) ;
157
+ //FbxExporters.Editor.IntegrationsUI.InstallMayaIntegration ();
166
158
}
167
159
168
160
GUILayout . FlexibleSpace ( ) ;
@@ -174,6 +166,49 @@ public override void OnInspectorGUI() {
174
166
}
175
167
}
176
168
169
+ private static string TryFindDCC ( string dccPath , string ext , ExportSettings . DCCType dccType ) {
170
+ string dccName = "" ;
171
+ switch ( dccType ) {
172
+ case ExportSettings . DCCType . Maya :
173
+ dccName = "maya" ;
174
+ break ;
175
+ case ExportSettings . DCCType . Max :
176
+ dccName = "3dsmax" ;
177
+ break ;
178
+ default :
179
+ throw new System . NotImplementedException ( ) ;
180
+ }
181
+
182
+ if ( Path . GetFileNameWithoutExtension ( dccPath ) . ToLower ( ) . Equals ( dccName ) ) {
183
+ return dccPath ;
184
+ }
185
+
186
+ // clicked on the wrong application, try to see if we can still find
187
+ // a dcc in this directory.
188
+ var dccDir = new DirectoryInfo ( Path . GetDirectoryName ( dccPath ) ) ;
189
+ FileSystemInfo [ ] files = { } ;
190
+ switch ( Application . platform ) {
191
+ case RuntimePlatform . OSXEditor :
192
+ files = dccDir . GetDirectories ( "*." + ext ) ;
193
+ break ;
194
+ case RuntimePlatform . WindowsEditor :
195
+ files = dccDir . GetFiles ( "*." + ext ) ;
196
+ break ;
197
+ default :
198
+ throw new System . NotImplementedException ( ) ;
199
+ }
200
+
201
+ string newDccPath = null ;
202
+ foreach ( var file in files ) {
203
+ var filename = Path . GetFileNameWithoutExtension ( file . Name ) . ToLower ( ) ;
204
+ if ( filename . Equals ( dccName ) ) {
205
+ newDccPath = file . FullName . Replace ( "\\ " , "/" ) ;
206
+ break ;
207
+ }
208
+ }
209
+ return newDccPath ;
210
+ }
211
+
177
212
}
178
213
179
214
[ FilePath ( "ProjectSettings/FbxExportSettings.asset" , FilePathAttribute . Location . ProjectFolder ) ]
0 commit comments