@@ -226,9 +226,12 @@ private static string TryFindDCC(string dccPath, string ext, ExportSettings.DCCT
226
226
public class ExportSettings : ScriptableSingleton < ExportSettings >
227
227
{
228
228
public const string kDefaultSavePath = "." ;
229
- private static List < string > s_PreferenceList = new List < string > ( ) { "maya" , "mayalt" , "3ds" , "blender" } ;
230
- public static string s_MaxName = "3ds Max " ;
231
- public static string s_MayaName = "Maya " ;
229
+ private static List < string > s_PreferenceList = new List < string > ( ) { kMayaOptionName , kMayaLtOptionName , kMaxOptionName , kBlenderOptionName } ;
230
+ //Any additional names require a space after the name
231
+ public const string kMaxOptionName = "3ds Max " ;
232
+ public const string kMayaOptionName = "Maya " ;
233
+ public const string kMayaLtOptionName = "MayaLT " ;
234
+ public const string kBlenderOptionName = "Blender " ;
232
235
233
236
/// <summary>
234
237
/// The path where all the different versions of Maya are installed
@@ -268,10 +271,10 @@ public static string kDefaultAdskRoot {
268
271
269
272
// List of names in order that they appear in option list
270
273
[ SerializeField ]
271
- public List < string > dccOptionNames ;
274
+ private List < string > dccOptionNames = new List < string > ( ) ;
272
275
// List of paths in order that they appear in the option list
273
276
[ SerializeField ]
274
- public List < string > dccOptionPaths ;
277
+ private List < string > dccOptionPaths ;
275
278
276
279
protected override void LoadDefaults ( )
277
280
{
@@ -287,7 +290,12 @@ protected override void LoadDefaults()
287
290
/// </summary>
288
291
/// <returns>The unique name.</returns>
289
292
/// <param name="name">Name.</param>
290
- public static string GetUniqueName ( string name ) {
293
+ public static string GetUniqueDCCOptionName ( string name ) {
294
+ Debug . Assert ( instance != null ) ;
295
+ if ( name == null )
296
+ {
297
+ return null ;
298
+ }
291
299
if ( ! instance . dccOptionNames . Contains ( name ) ) {
292
300
return name ;
293
301
}
@@ -314,6 +322,16 @@ public static string GetUniqueName(string name){
314
322
return uniqueName ;
315
323
}
316
324
325
+ public void SetDCCOptionNames ( List < string > newList )
326
+ {
327
+ dccOptionNames = newList ;
328
+ }
329
+
330
+ public void ClearDCCOptionNames ( )
331
+ {
332
+ dccOptionNames . Clear ( ) ;
333
+ }
334
+
317
335
/// <summary>
318
336
///
319
337
/// Find the latest program available and make that the default choice.
@@ -335,6 +353,10 @@ public int GetPreferredDCCApp()
335
353
for ( int i = 0 ; i < dccOptionNames . Count ; i ++ )
336
354
{
337
355
int versionToCheck = FindDCCVersion ( dccOptionNames [ i ] ) ;
356
+ if ( versionToCheck == - 1 )
357
+ {
358
+ continue ;
359
+ }
338
360
if ( versionToCheck > newestDCCVersionNumber )
339
361
{
340
362
newestDCCVersionIndex = i ;
@@ -362,16 +384,23 @@ public int GetPreferredDCCApp()
362
384
/// <returns></returns>
363
385
private int ChoosePreferredDCCApp ( int optionA , int optionB )
364
386
{
365
- int scoreA = s_PreferenceList . IndexOf ( GetAppNameFromFolderName ( dccOptionNames [ optionA ] ) ) ;
366
- int scoreB = s_PreferenceList . IndexOf ( GetAppNameFromFolderName ( dccOptionNames [ optionB ] ) ) ;
387
+ Debug . Assert ( optionA >= 0 && optionB >= 0 && optionA < dccOptionNames . Count && optionB < dccOptionNames . Count ) ;
388
+ if ( dccOptionNames . Count == 0 )
389
+ {
390
+ return - 1 ;
391
+ }
392
+ var appA = dccOptionNames [ optionA ] ;
393
+ var appB = dccOptionNames [ optionB ] ;
394
+ if ( appA == null || appB == null || appA . Length <= 0 || appB . Length <= 0 )
395
+ {
396
+ return - 1 ;
397
+ }
367
398
368
- return scoreA < scoreB ? optionA : optionB ;
369
- }
399
+ //We assume that the option names have a
400
+ int scoreA = s_PreferenceList . IndexOf ( appA . Split ( ' ' ) [ 0 ] ) ;
401
+ int scoreB = s_PreferenceList . IndexOf ( appB . Split ( ' ' ) [ 0 ] ) ;
370
402
371
- ///
372
- private string GetAppNameFromFolderName ( string originalString )
373
- {
374
- return originalString . ToLower ( ) . Split ( ' ' ) [ 0 ] ;
403
+ return scoreA < scoreB ? optionA : optionB ;
375
404
}
376
405
377
406
/// <summary>
@@ -448,7 +477,7 @@ private static void FindDCCInstalls() {
448
477
}
449
478
string version = product . Substring ( "maya" . Length ) ;
450
479
dccOptionPath . Add ( GetMayaExePath ( productDir . FullName . Replace ( "\\ " , "/" ) ) ) ;
451
- dccOptionName . Add ( GetUniqueName ( s_MayaName + version ) ) ;
480
+ dccOptionName . Add ( GetUniqueDCCOptionName ( kMayaOptionName + version ) ) ;
452
481
}
453
482
454
483
if ( product . StartsWith ( "3ds max" , StringComparison . InvariantCultureIgnoreCase ) ) {
@@ -458,7 +487,7 @@ private static void FindDCCInstalls() {
458
487
}
459
488
string version = product . Substring ( "3ds max " . Length ) ;
460
489
dccOptionPath . Add ( exePath ) ;
461
- dccOptionName . Add ( GetUniqueName ( s_MaxName + version ) ) ;
490
+ dccOptionName . Add ( GetUniqueDCCOptionName ( kMaxOptionName + version ) ) ;
462
491
}
463
492
}
464
493
instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
@@ -565,7 +594,7 @@ public static void AddDCCOption(string newOption, DCCType dcc){
565
594
Debug . LogError ( string . Format ( "Unity Integration does not support Maya LT: \" {0}\" " , newOption ) ) ;
566
595
return ;
567
596
}
568
- optionName = GetUniqueName ( "Maya " + version ) ;
597
+ optionName = GetUniqueDCCOptionName ( "Maya " + version ) ;
569
598
break ;
570
599
case DCCType . Max :
571
600
optionName = GetMaxOptionName ( newOption ) ;
@@ -608,7 +637,7 @@ static string AskMayaVersion(string exePath) {
608
637
/// <returns>The 3DsMax dropdown option label.</returns>
609
638
/// <param name="exePath">Exe path.</param>
610
639
public static string GetMaxOptionName ( string exePath ) {
611
- return GetUniqueName ( Path . GetFileName ( Path . GetDirectoryName ( exePath ) ) ) ;
640
+ return GetUniqueDCCOptionName ( Path . GetFileName ( Path . GetDirectoryName ( exePath ) ) ) ;
612
641
}
613
642
614
643
public static bool IsEarlierThanMax2017 ( string AppName ) {
0 commit comments