@@ -106,26 +106,26 @@ public override void OnInspectorGUI() {
106
106
"Select the version of Maya where you would like to install the Unity integration." ) ) ;
107
107
108
108
// dropdown to select Maya version to use
109
- var options = ExportSettings . GetMayaOptions ( ) ;
109
+ var options = ExportSettings . GetDCCOptions ( ) ;
110
110
// make sure we never initially have browse selected
111
- if ( exportSettings . selectedMayaApp == options . Length - 1 ) {
112
- exportSettings . selectedMayaApp = 0 ;
111
+ if ( exportSettings . selectedDCCApp == options . Length - 1 ) {
112
+ exportSettings . selectedDCCApp = 0 ;
113
113
}
114
- int oldValue = exportSettings . selectedMayaApp ;
115
- exportSettings . selectedMayaApp = EditorGUILayout . Popup ( exportSettings . selectedMayaApp , options ) ;
116
- if ( exportSettings . selectedMayaApp == options . Length - 1 ) {
114
+ int oldValue = exportSettings . selectedDCCApp ;
115
+ exportSettings . selectedDCCApp = EditorGUILayout . Popup ( exportSettings . selectedDCCApp , options ) ;
116
+ if ( exportSettings . selectedDCCApp == options . Length - 1 ) {
117
117
var ext = "exe" ;
118
118
#if UNITY_EDITOR_OSX
119
119
ext = "app" ;
120
120
#endif
121
- string mayaPath = EditorUtility . OpenFilePanel ( "Select Maya Application" , ExportSettings . kDefaultAdskRoot , ext ) ;
121
+ string dccPath = EditorUtility . OpenFilePanel ( "Select DCC Application" , ExportSettings . kDefaultAdskRoot , ext ) ;
122
122
123
123
// check that the path is valid and references the maya executable
124
- if ( ! string . IsNullOrEmpty ( mayaPath ) ) {
125
- if ( ! Path . GetFileNameWithoutExtension ( mayaPath ) . ToLower ( ) . Equals ( "maya" ) ) {
124
+ if ( ! string . IsNullOrEmpty ( dccPath ) ) {
125
+ if ( ! Path . GetFileNameWithoutExtension ( dccPath ) . ToLower ( ) . Equals ( "maya" ) ) {
126
126
// clicked on the wrong application, try to see if we can still find
127
127
// maya in this directory.
128
- var mayaDir = new DirectoryInfo ( Path . GetDirectoryName ( mayaPath ) ) ;
128
+ var mayaDir = new DirectoryInfo ( Path . GetDirectoryName ( dccPath ) ) ;
129
129
#if UNITY_EDITOR_OSX
130
130
var files = mayaDir . GetDirectories ( "*." + ext ) ;
131
131
#else
@@ -135,21 +135,21 @@ public override void OnInspectorGUI() {
135
135
foreach ( var file in files ) {
136
136
var filename = Path . GetFileNameWithoutExtension ( file . Name ) . ToLower ( ) ;
137
137
if ( filename . Equals ( "maya" ) ) {
138
- mayaPath = file . FullName . Replace ( "\\ " , "/" ) ;
138
+ dccPath = file . FullName . Replace ( "\\ " , "/" ) ;
139
139
foundMaya = true ;
140
140
break ;
141
141
}
142
142
}
143
143
if ( ! foundMaya ) {
144
144
Debug . LogError ( string . Format ( "Could not find Maya at: \" {0}\" " , mayaDir . FullName ) ) ;
145
- exportSettings . selectedMayaApp = oldValue ;
145
+ exportSettings . selectedDCCApp = oldValue ;
146
146
return ;
147
147
}
148
148
}
149
- ExportSettings . AddMayaOption ( mayaPath ) ;
149
+ ExportSettings . AddDCCOption ( dccPath ) ;
150
150
Repaint ( ) ;
151
151
} else {
152
- exportSettings . selectedMayaApp = oldValue ;
152
+ exportSettings . selectedDCCApp = oldValue ;
153
153
}
154
154
}
155
155
GUILayout . EndHorizontal ( ) ;
@@ -206,7 +206,7 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
206
206
[ HideInInspector ]
207
207
public bool keepOriginalAfterConvert ;
208
208
209
- public int selectedMayaApp = 0 ;
209
+ public int selectedDCCApp = 0 ;
210
210
211
211
[ SerializeField ]
212
212
public UnityEngine . Object turntableScene ;
@@ -226,10 +226,10 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
226
226
227
227
// List of names in order that they appear in option list
228
228
[ SerializeField ]
229
- private List < string > mayaOptionNames ;
229
+ private List < string > dccOptionNames ;
230
230
// List of paths in order that they appear in the option list
231
231
[ SerializeField ]
232
- private List < string > mayaOptionPaths ;
232
+ private List < string > dccOptionPaths ;
233
233
234
234
protected override void LoadDefaults ( )
235
235
{
@@ -238,8 +238,8 @@ protected override void LoadDefaults()
238
238
keepOriginalAfterConvert = false ;
239
239
convertToModelSavePath = kDefaultSavePath ;
240
240
turntableScene = null ;
241
- mayaOptionPaths = null ;
242
- mayaOptionNames = null ;
241
+ dccOptionPaths = null ;
242
+ dccOptionNames = null ;
243
243
}
244
244
245
245
/// <summary>
@@ -248,7 +248,7 @@ protected override void LoadDefaults()
248
248
/// <returns>The unique name.</returns>
249
249
/// <param name="name">Name.</param>
250
250
private static string GetUniqueName ( string name ) {
251
- if ( ! instance . mayaOptionNames . Contains ( name ) ) {
251
+ if ( ! instance . dccOptionNames . Contains ( name ) ) {
252
252
return name ;
253
253
}
254
254
var format = "{1} ({0})" ;
@@ -269,22 +269,44 @@ private static string GetUniqueName(string name){
269
269
do {
270
270
uniqueName = string . Format ( format , index , name ) ;
271
271
index ++ ;
272
- } while ( instance . mayaOptionNames . Contains ( name ) ) ;
272
+ } while ( instance . dccOptionNames . Contains ( name ) ) ;
273
273
274
274
return uniqueName ;
275
275
}
276
276
277
+ /// <summary>
278
+ /// Find 3DsMax installations at default install path.
279
+ /// Add results to given dictionary.
280
+ /// </summary>
281
+ private static void FindMaxInstalls ( ) {
282
+ var maxOptionName = instance . dccOptionNames ;
283
+ var maxOptionPath = instance . dccOptionPaths ;
284
+
285
+ // List that directory and find the right version:
286
+ // either the newest version, or the exact version we wanted.
287
+ var adskRoot = new System . IO . DirectoryInfo ( kDefaultAdskRoot ) ;
288
+ foreach ( var productDir in adskRoot . GetDirectories ( ) ) {
289
+ var product = productDir . Name ;
290
+
291
+ // Only accept those that start with 'maya' in either case.
292
+ if ( ! product . StartsWith ( "3ds max" , StringComparison . InvariantCultureIgnoreCase ) ) {
293
+ continue ;
294
+ }
295
+ string version = product . Substring ( "3ds max " . Length ) ;
296
+ maxOptionPath . Add ( string . Format ( "{0}/{1}" , productDir . FullName . Replace ( "\\ " , "/" ) , "3dsmax.exe" ) ) ;
297
+ maxOptionName . Add ( GetUniqueName ( "3Ds Max " + version ) ) ;
298
+ }
299
+ }
300
+
277
301
/// <summary>
278
302
/// Find Maya installations at default install path.
279
303
/// Add results to given dictionary.
280
304
///
281
305
/// If MAYA_LOCATION is set, add this to the list as well.
282
306
/// </summary>
283
307
private static void FindMayaInstalls ( ) {
284
- instance . mayaOptionPaths = new List < string > ( ) ;
285
- instance . mayaOptionNames = new List < string > ( ) ;
286
- var mayaOptionName = instance . mayaOptionNames ;
287
- var mayaOptionPath = instance . mayaOptionPaths ;
308
+ var mayaOptionName = instance . dccOptionNames ;
309
+ var mayaOptionPath = instance . dccOptionPaths ;
288
310
289
311
// If the location is given by the environment, use it.
290
312
var location = System . Environment . GetEnvironmentVariable ( "MAYA_LOCATION" ) ;
@@ -340,57 +362,61 @@ private static string GetMayaExePath(string location)
340
362
#endif
341
363
}
342
364
343
- public static GUIContent [ ] GetMayaOptions ( ) {
344
- if ( instance . mayaOptionNames == null ||
345
- instance . mayaOptionNames . Count != instance . mayaOptionPaths . Count ||
346
- instance . mayaOptionNames . Count == 0 ) {
365
+ public static GUIContent [ ] GetDCCOptions ( ) {
366
+ if ( instance . dccOptionNames == null ||
367
+ instance . dccOptionNames . Count != instance . dccOptionPaths . Count ||
368
+ instance . dccOptionNames . Count == 0 ) {
369
+
370
+ instance . dccOptionPaths = new List < string > ( ) ;
371
+ instance . dccOptionNames = new List < string > ( ) ;
347
372
FindMayaInstalls ( ) ;
373
+ FindMaxInstalls ( ) ;
348
374
}
349
375
350
376
// remove options that no longer exist
351
377
List < int > toDelete = new List < int > ( ) ;
352
- for ( int i = 0 ; i < instance . mayaOptionPaths . Count ; i ++ ) {
353
- var mayaPath = instance . mayaOptionPaths [ i ] ;
378
+ for ( int i = 0 ; i < instance . dccOptionPaths . Count ; i ++ ) {
379
+ var mayaPath = instance . dccOptionPaths [ i ] ;
354
380
if ( ! File . Exists ( mayaPath ) ) {
355
- if ( i == instance . selectedMayaApp ) {
356
- instance . selectedMayaApp = 0 ;
381
+ if ( i == instance . selectedDCCApp ) {
382
+ instance . selectedDCCApp = 0 ;
357
383
}
358
- instance . mayaOptionNames . RemoveAt ( i ) ;
384
+ instance . dccOptionNames . RemoveAt ( i ) ;
359
385
toDelete . Add ( i ) ;
360
386
}
361
387
}
362
388
foreach ( var index in toDelete ) {
363
- instance . mayaOptionPaths . RemoveAt ( index ) ;
389
+ instance . dccOptionPaths . RemoveAt ( index ) ;
364
390
}
365
391
366
- GUIContent [ ] optionArray = new GUIContent [ instance . mayaOptionPaths . Count + 1 ] ;
367
- for ( int i = 0 ; i < instance . mayaOptionPaths . Count ; i ++ ) {
392
+ GUIContent [ ] optionArray = new GUIContent [ instance . dccOptionPaths . Count + 1 ] ;
393
+ for ( int i = 0 ; i < instance . dccOptionPaths . Count ; i ++ ) {
368
394
optionArray [ i ] = new GUIContent (
369
- instance . mayaOptionNames [ i ] ,
370
- instance . mayaOptionPaths [ i ]
395
+ instance . dccOptionNames [ i ] ,
396
+ instance . dccOptionPaths [ i ]
371
397
) ;
372
398
}
373
399
optionArray [ optionArray . Length - 1 ] = new GUIContent ( "Browse..." ) ;
374
400
375
401
return optionArray ;
376
402
}
377
403
378
- public static void AddMayaOption ( string newOption ) {
404
+ public static void AddDCCOption ( string newOption ) {
379
405
// on OSX we get a path ending in .app, which is not quite the exe
380
406
#if UNITY_EDITOR_OSX
381
407
newOption = GetMayaExePath ( newOption ) ;
382
408
#endif
383
409
384
- var mayaOptionPaths = instance . mayaOptionPaths ;
410
+ var mayaOptionPaths = instance . dccOptionPaths ;
385
411
if ( mayaOptionPaths . Contains ( newOption ) ) {
386
- instance . selectedMayaApp = mayaOptionPaths . IndexOf ( newOption ) ;
412
+ instance . selectedDCCApp = mayaOptionPaths . IndexOf ( newOption ) ;
387
413
return ;
388
414
}
389
415
// get the version
390
416
var version = AskMayaVersion ( newOption ) ;
391
- instance . mayaOptionNames . Add ( GetUniqueName ( "Maya " + version ) ) ;
417
+ instance . dccOptionNames . Add ( GetUniqueName ( "Maya " + version ) ) ;
392
418
mayaOptionPaths . Add ( newOption ) ;
393
- instance . selectedMayaApp = mayaOptionPaths . Count - 1 ;
419
+ instance . selectedDCCApp = mayaOptionPaths . Count - 1 ;
394
420
}
395
421
396
422
/// <summary>
@@ -418,7 +444,7 @@ static string AskMayaVersion(string exePath) {
418
444
419
445
public static string GetSelectedMayaPath ( )
420
446
{
421
- return instance . mayaOptionPaths [ instance . selectedMayaApp ] ;
447
+ return instance . dccOptionPaths [ instance . selectedDCCApp ] ;
422
448
}
423
449
424
450
public static string GetTurnTableSceneName ( ) {
0 commit comments