@@ -324,6 +324,7 @@ public int FindMostRecentProgram()
324
324
int newestMayaVersion = - 1 ;
325
325
int savedMayaVersionNumber = 0 ;
326
326
int newestMaxVersion = - 1 ;
327
+ int savedMaxVersionNumber = 0 ;
327
328
328
329
for ( int i = 0 ; i < instance . dccOptionPaths . Count ; i ++ )
329
330
{
@@ -332,33 +333,33 @@ public int FindMostRecentProgram()
332
333
if ( newestMayaVersion == - 1 )
333
334
{
334
335
newestMayaVersion = 0 ;
335
- savedMayaVersionNumber = int . Parse ( AskMayaVersion ( instance . dccOptionPaths [ i ] ) ) ;
336
+ savedMayaVersionNumber = FindMayaVersion ( dccOptionPaths [ i ] ) ;
336
337
continue ;
337
338
}
338
339
339
340
//Check if the path we are considering is newer than the previously saved one
340
- int versionToCheck ;
341
- if ( int . TryParse ( AskMayaVersion ( instance . dccOptionPaths [ i ] ) , out versionToCheck ) )
342
- {
341
+ int versionToCheck = FindMayaVersion ( dccOptionPaths [ i ] ) ;
343
342
if ( versionToCheck > savedMayaVersionNumber )
344
343
{
345
344
newestMayaVersion = i ;
346
345
savedMayaVersionNumber = versionToCheck ;
347
- }
348
- }
346
+ }
349
347
}
350
- else if ( instance . dccOptionPaths [ i ] . ToLower ( ) . Contains ( "max" ) && newestMayaVersion == - 1 )
348
+ else if ( newestMayaVersion == - 1 && instance . dccOptionPaths [ i ] . ToLower ( ) . Contains ( "max" ) )
351
349
{
352
350
if ( newestMaxVersion == - 1 )
353
351
{
354
352
newestMaxVersion = 0 ;
353
+ savedMaxVersionNumber = FindMaxVersion ( dccOptionPaths [ newestMaxVersion ] ) ;
355
354
continue ;
356
355
}
357
356
358
357
//Check if the path we are considering is newer than the previously saved one
359
- if ( FindMaxVersion ( dccOptionPaths [ i ] ) > FindMaxVersion ( dccOptionPaths [ newestMaxVersion ] ) )
358
+ int versionToCheck = FindMaxVersion ( dccOptionPaths [ i ] ) ;
359
+ if ( versionToCheck > savedMaxVersionNumber )
360
360
{
361
361
newestMaxVersion = i ;
362
+ savedMaxVersionNumber = versionToCheck ;
362
363
}
363
364
364
365
}
@@ -400,6 +401,28 @@ private static int FindMaxVersion(string path)
400
401
}
401
402
}
402
403
404
+ /// <summary>
405
+ /// Finds the Maya version based off of the title of the application
406
+ /// </summary>
407
+ /// <param name="path"></param>
408
+ /// <returns> the year/version OR -1 if the year could not be parsed </returns>
409
+ private static int FindMayaVersion ( string path )
410
+ {
411
+ var fileName = Path . GetFileName ( Path . GetDirectoryName ( path ) ) . ToLower ( ) ;
412
+ fileName = fileName . Replace ( "maya" , "" ) . Trim ( ) ;
413
+
414
+ int version ;
415
+
416
+ if ( int . TryParse ( fileName , out version ) )
417
+ {
418
+ return version ;
419
+ }
420
+ else
421
+ {
422
+ return - 1 ;
423
+ }
424
+ }
425
+
403
426
/// <summary>
404
427
/// Find Maya and 3DsMax installations at default install path.
405
428
/// Add results to given dictionary.
@@ -497,7 +520,7 @@ public static GUIContent[] GetDCCOptions(){
497
520
var dccPath = instance . dccOptionPaths [ i ] ;
498
521
if ( ! File . Exists ( dccPath ) ) {
499
522
if ( i == instance . selectedDCCApp ) {
500
- instance . selectedDCCApp = 0 ;
523
+ instance . selectedDCCApp = instance . FindMostRecentProgram ( ) ;
501
524
}
502
525
namesToDelete . Add ( instance . dccOptionNames [ i ] ) ;
503
526
pathsToDelete . Add ( dccPath ) ;
0 commit comments