@@ -114,10 +114,17 @@ public override void OnInspectorGUI() {
114
114
int oldValue = exportSettings . selectedMayaApp ;
115
115
exportSettings . selectedMayaApp = EditorGUILayout . Popup ( exportSettings . selectedMayaApp , options ) ;
116
116
if ( exportSettings . selectedMayaApp == 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 NotImplementedException ( ) ;
127
+ }
121
128
string mayaPath = EditorUtility . OpenFilePanel ( "Select Maya Application" , ExportSettings . kDefaultAdskRoot , ext ) ;
122
129
123
130
// check that the path is valid and references the maya executable
@@ -126,11 +133,20 @@ public override void OnInspectorGUI() {
126
133
// clicked on the wrong application, try to see if we can still find
127
134
// maya in this directory.
128
135
var mayaDir = new DirectoryInfo ( Path . GetDirectoryName ( mayaPath ) ) ;
129
- #if UNITY_EDITOR_OSX
130
- var files = mayaDir . GetDirectories ( "*." + ext ) ;
131
- #else
132
- var files = mayaDir . GetFiles ( "*." + ext ) ;
133
- #endif
136
+
137
+ FileSystemInfo [ ] files = null ;
138
+
139
+ switch ( Application . platform ) {
140
+ case RuntimePlatform . WindowsEditor :
141
+ files = mayaDir . GetFiles ( "*." + ext ) ;
142
+ break ;
143
+ case RuntimePlatform . OSXEditor :
144
+ files = mayaDir . GetDirectories ( "*." + ext ) ;
145
+ break ;
146
+ default :
147
+ throw new NotImplementedException ( ) ;
148
+ }
149
+
134
150
bool foundMaya = false ;
135
151
foreach ( var file in files ) {
136
152
var filename = Path . GetFileNameWithoutExtension ( file . Name ) . ToLower ( ) ;
@@ -181,15 +197,18 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
181
197
/// The path where all the different versions of Maya are installed
182
198
/// by default. Depends on the platform.
183
199
/// </summary>
184
- public const string kDefaultAdskRoot =
185
- #if UNITY_EDITOR_OSX
186
- "/Applications/Autodesk"
187
- #elif UNITY_EDITOR_LINUX
188
- "/usr/autodesk"
189
- #else // WINDOWS
190
- "C:/Program Files/Autodesk"
191
- #endif
192
- ;
200
+ public static string kDefaultAdskRoot {
201
+ get {
202
+ switch ( Application . platform ) {
203
+ case RuntimePlatform . WindowsEditor :
204
+ return "C:/Program Files/Autodesk" ;
205
+ case RuntimePlatform . OSXEditor :
206
+ return "/Applications/Autodesk" ;
207
+ default :
208
+ throw new NotImplementedException ( ) ;
209
+ }
210
+ }
211
+ }
193
212
194
213
// Note: default values are set in LoadDefaults().
195
214
public bool mayaCompatibleNames ;
@@ -317,23 +336,24 @@ private static void FindMayaInstalls() {
317
336
/// <param name="location">Location of Maya install.</param>
318
337
private static string GetMayaExePath ( string location )
319
338
{
320
- #if UNITY_EDITOR_OSX
321
- // MAYA_LOCATION on mac is set by Autodesk to be the
322
- // Contents directory. But let's make it easier on people
323
- // and allow just having it be the app bundle or a
324
- // directory that holds the app bundle.
325
- if ( location . EndsWith ( ".app/Contents" ) ) {
326
- return location + "/MacOS/Maya" ;
327
- } else if ( location . EndsWith ( ".app" ) ) {
328
- return location + "/Contents/MacOS/Maya" ;
329
- } else {
330
- return location + "/Maya.app/Contents/MacOS/Maya" ;
339
+ switch ( Application . platform ) {
340
+ case RuntimePlatform . WindowsEditor :
341
+ return location + "/bin/maya.exe" ;
342
+ case RuntimePlatform . OSXEditor :
343
+ // MAYA_LOCATION on mac is set by Autodesk to be the
344
+ // Contents directory. But let's make it easier on people
345
+ // and allow just having it be the app bundle or a
346
+ // directory that holds the app bundle.
347
+ if ( location . EndsWith ( ".app/Contents" ) ) {
348
+ return location + "/MacOS/Maya" ;
349
+ } else if ( location . EndsWith ( ".app" ) ) {
350
+ return location + "/Contents/MacOS/Maya" ;
351
+ } else {
352
+ return location + "/Maya.app/Contents/MacOS/Maya" ;
353
+ }
354
+ default :
355
+ throw new NotImplementedException ( ) ;
331
356
}
332
- #elif UNITY_EDITOR_LINUX
333
- return location + "/bin/maya" ;
334
- #else // WINDOWS
335
- return location + "/bin/maya.exe" ;
336
- #endif
337
357
}
338
358
339
359
public static GUIContent [ ] GetMayaOptions ( ) {
@@ -373,9 +393,9 @@ public static GUIContent[] GetMayaOptions(){
373
393
374
394
public static void AddMayaOption ( string newOption ) {
375
395
// on OSX we get a path ending in .app, which is not quite the exe
376
- # if UNITY_EDITOR_OSX
377
- newOption = GetMayaExePath ( newOption ) ;
378
- #endif
396
+ if ( Application . platform == RuntimePlatform . OSXEditor ) {
397
+ newOption = GetMayaExePath ( newOption ) ;
398
+ }
379
399
380
400
var mayaOptionPaths = instance . mayaOptionPaths ;
381
401
if ( mayaOptionPaths . Contains ( newOption ) ) {
0 commit comments