@@ -121,7 +121,7 @@ public override void OnInspectorGUI() {
121
121
throw new System . NotImplementedException ( ) ;
122
122
}
123
123
124
- string dccPath = EditorUtility . OpenFilePanel ( "Select Digital Content Creation Application" , ExportSettings . kDefaultAdskRoot , ext ) ;
124
+ string dccPath = EditorUtility . OpenFilePanel ( "Select Digital Content Creation Application" , ExportSettings . GetFirstValidVendorLocation ( ) , ext ) ;
125
125
126
126
// check that the path is valid and references the maya executable
127
127
if ( ! string . IsNullOrEmpty ( dccPath ) ) {
@@ -238,18 +238,37 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
238
238
public const string kBlenderOptionName = "Blender " ;
239
239
240
240
/// <summary>
241
- /// The path where all the different versions of Maya are installed
241
+ /// The paths where all the different versions of Maya are installed
242
242
/// by default. Depends on the platform.
243
243
/// </summary>
244
- public static string kDefaultAdskRoot {
244
+ public static string [ ] DCCVendorLocations {
245
245
get {
246
- switch ( Application . platform ) {
247
- case RuntimePlatform . WindowsEditor :
248
- return "C:/Program Files/Autodesk" ;
249
- case RuntimePlatform . OSXEditor :
250
- return "/Applications/Autodesk" ;
251
- default :
252
- throw new NotImplementedException ( ) ;
246
+ var environmentVariable = Environment . GetEnvironmentVariable ( "UNITY_FBX_3DAPP_VENDOR_LOCATIONS" ) ;
247
+ if ( environmentVariable != null )
248
+ {
249
+ string [ ] locations = environmentVariable . Split ( ';' ) ;
250
+ List < string > locationsList = new List < string > ( ) ;
251
+ for ( int i = 0 ; i < locations . Length ; i ++ )
252
+ {
253
+ if ( Directory . Exists ( locations [ i ] ) )
254
+ {
255
+ locationsList . Add ( locations [ i ] ) ;
256
+ }
257
+ }
258
+ if ( locationsList . Count > 0 )
259
+ {
260
+ return locationsList . ToArray ( ) ;
261
+ }
262
+ }
263
+
264
+ switch ( Application . platform )
265
+ {
266
+ case RuntimePlatform . WindowsEditor :
267
+ return new string [ ] { "C:/Program Files/Autodesk" , "D:/Program Files/Autodesk" } ;
268
+ case RuntimePlatform . OSXEditor :
269
+ return new string [ ] { "/Applications/Autodesk" } ;
270
+ default :
271
+ throw new NotImplementedException ( ) ;
253
272
}
254
273
}
255
274
}
@@ -458,53 +477,73 @@ private static void FindDCCInstalls() {
458
477
var dccOptionName = instance . dccOptionNames ;
459
478
var dccOptionPath = instance . dccOptionPaths ;
460
479
461
- // If the location is given by the environment, use it.
462
- var location = System . Environment . GetEnvironmentVariable ( "MAYA_LOCATION" ) ;
463
- if ( ! string . IsNullOrEmpty ( location ) ) {
464
- location = location . TrimEnd ( '/' ) ;
465
- dccOptionPath . Add ( GetMayaExePath ( location . Replace ( "\\ " , "/" ) ) ) ;
466
- dccOptionName . Add ( "MAYA_LOCATION" ) ;
467
- }
468
-
469
- if ( ! Directory . Exists ( kDefaultAdskRoot ) ) {
470
- // no autodesk products installed
471
- return ;
472
- }
473
- // List that directory and find the right version:
474
- // either the newest version, or the exact version we wanted.
475
- var adskRoot = new System . IO . DirectoryInfo ( kDefaultAdskRoot ) ;
476
- foreach ( var productDir in adskRoot . GetDirectories ( ) ) {
477
- var product = productDir . Name ;
480
+ for ( int i = 0 ; i < DCCVendorLocations . Length ; i ++ )
481
+ {
482
+ if ( ! Directory . Exists ( DCCVendorLocations [ i ] ) )
483
+ {
484
+ // no autodesk products installed
485
+ continue ;
486
+ }
487
+ // List that directory and find the right version:
488
+ // either the newest version, or the exact version we wanted.
489
+ var adskRoot = new System . IO . DirectoryInfo ( DCCVendorLocations [ i ] ) ;
490
+ foreach ( var productDir in adskRoot . GetDirectories ( ) )
491
+ {
492
+ var product = productDir . Name ;
478
493
479
- // Only accept those that start with 'maya' in either case.
480
- if ( product . StartsWith ( "maya" , StringComparison . InvariantCultureIgnoreCase ) ) {
481
- // UNI-29074 TODO: add Maya LT support
482
- // Reject MayaLT -- it doesn't have plugins.
483
- if ( product . StartsWith ( "mayalt" , StringComparison . InvariantCultureIgnoreCase ) ) {
484
- continue ;
494
+ // Only accept those that start with 'maya' in either case.
495
+ if ( product . StartsWith ( "maya" , StringComparison . InvariantCultureIgnoreCase ) )
496
+ {
497
+ // UNI-29074 TODO: add Maya LT support
498
+ // Reject MayaLT -- it doesn't have plugins.
499
+ if ( product . StartsWith ( "mayalt" , StringComparison . InvariantCultureIgnoreCase ) )
500
+ {
501
+ continue ;
502
+ }
503
+ string version = product . Substring ( "maya" . Length ) ;
504
+ dccOptionPath . Add ( GetMayaExePath ( productDir . FullName . Replace ( "\\ " , "/" ) ) ) ;
505
+ dccOptionName . Add ( GetUniqueDCCOptionName ( kMayaOptionName + version ) ) ;
485
506
}
486
- string version = product . Substring ( "maya" . Length ) ;
487
- dccOptionPath . Add ( GetMayaExePath ( productDir . FullName . Replace ( "\\ " , "/" ) ) ) ;
488
- dccOptionName . Add ( GetUniqueDCCOptionName ( kMayaOptionName + version ) ) ;
489
- }
490
507
491
- if ( product . StartsWith ( "3ds max" , StringComparison . InvariantCultureIgnoreCase ) ) {
492
- var exePath = string . Format ( "{0}/{1}" , productDir . FullName . Replace ( "\\ " , "/" ) , "3dsmax.exe" ) ;
508
+ if ( product . StartsWith ( "3ds max" , StringComparison . InvariantCultureIgnoreCase ) )
509
+ {
510
+ var exePath = string . Format ( "{0}/{1}" , productDir . FullName . Replace ( "\\ " , "/" ) , "3dsmax.exe" ) ;
511
+
512
+ string version = product . Substring ( "3ds max " . Length ) ;
513
+ var maxOptionName = GetUniqueDCCOptionName ( kMaxOptionName + version ) ;
493
514
494
- string version = product . Substring ( "3ds max " . Length ) ;
495
- var maxOptionName = GetUniqueDCCOptionName ( kMaxOptionName + version ) ;
515
+ if ( IsEarlierThanMax2017 ( maxOptionName ) )
516
+ {
517
+ continue ;
518
+ }
496
519
497
- if ( IsEarlierThanMax2017 ( maxOptionName ) ) {
498
- continue ;
520
+ dccOptionPath . Add ( exePath ) ;
521
+ dccOptionName . Add ( maxOptionName ) ;
499
522
}
500
-
501
- dccOptionPath . Add ( exePath ) ;
502
- dccOptionName . Add ( maxOptionName ) ;
503
523
}
504
524
}
505
525
instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
506
526
}
507
527
528
+ /// <summary>
529
+ /// Returns the first valid folder in our list of vendor locations
530
+ /// </summary>
531
+ /// <returns>The first valid vendor location</returns>
532
+ public static string GetFirstValidVendorLocation ( )
533
+ {
534
+ string [ ] locations = DCCVendorLocations ;
535
+ for ( int i = 0 ; i < locations . Length ; i ++ )
536
+ {
537
+ //Look through the list of locations we have and take the first valid one
538
+ if ( Directory . Exists ( locations [ i ] ) )
539
+ {
540
+ return locations [ i ] ;
541
+ }
542
+ }
543
+ //if no valid locations exist, just take us to the project folder
544
+ return Directory . GetCurrentDirectory ( ) ;
545
+ }
546
+
508
547
/// <summary>
509
548
/// Gets the maya exe at Maya install location.
510
549
/// </summary>
@@ -563,6 +602,7 @@ public static GUIContent[] GetDCCOptions(){
563
602
}
564
603
565
604
if ( instance . dccOptionPaths . Count <= 0 ) {
605
+ instance . selectedDCCApp = 0 ;
566
606
return new GUIContent [ ] {
567
607
new GUIContent ( "<No 3D Application found>" )
568
608
} ;
0 commit comments