@@ -52,6 +52,16 @@ public override void OnInspectorGUI() {
52
52
exportSettings . centerObjects
53
53
) ;
54
54
55
+ EditorGUILayout . Space ( ) ;
56
+
57
+ GUILayout . BeginHorizontal ( ) ;
58
+ GUILayout . Label ( new GUIContent ( "Export Format:" , "Export the FBX file in the standard binary format." +
59
+ " Select ASCII to export the FBX file in ASCII format." ) , GUILayout . Width ( LabelWidth - 3 ) ) ;
60
+ exportSettings . ExportFormatSelection = EditorGUILayout . Popup ( exportSettings . ExportFormatSelection , new string [ ] { "Binary" , "ASCII" } ) ;
61
+ GUILayout . EndHorizontal ( ) ;
62
+
63
+ EditorGUILayout . Space ( ) ;
64
+
55
65
GUILayout . BeginHorizontal ( ) ;
56
66
GUILayout . Label ( new GUIContent (
57
67
"Export Path:" ,
@@ -118,7 +128,7 @@ public override void OnInspectorGUI() {
118
128
throw new System . NotImplementedException ( ) ;
119
129
}
120
130
121
- string dccPath = EditorUtility . OpenFilePanel ( "Select Digital Content Creation Application" , ExportSettings . kDefaultAdskRoot , ext ) ;
131
+ string dccPath = EditorUtility . OpenFilePanel ( "Select Digital Content Creation Application" , ExportSettings . GetFirstValidVendorLocation ( ) , ext ) ;
122
132
123
133
// check that the path is valid and references the maya executable
124
134
if ( ! string . IsNullOrEmpty ( dccPath ) ) {
@@ -139,7 +149,9 @@ public override void OnInspectorGUI() {
139
149
}
140
150
GUILayout . EndHorizontal ( ) ;
141
151
142
- var installIntegrationContent = new GUIContent (
152
+ EditorGUILayout . Space ( ) ;
153
+
154
+ var installIntegrationContent = new GUIContent (
143
155
"Install Unity Integration" ,
144
156
"Install and configure the Unity integration for the selected 3D application so that you can import and export directly with this project." ) ;
145
157
if ( GUILayout . Button ( installIntegrationContent ) ) {
@@ -219,18 +231,37 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
219
231
public const string kBlenderOptionName = "Blender " ;
220
232
221
233
/// <summary>
222
- /// The path where all the different versions of Maya are installed
234
+ /// The paths where all the different versions of Maya are installed
223
235
/// by default. Depends on the platform.
224
236
/// </summary>
225
- public static string kDefaultAdskRoot {
237
+ public static string [ ] DCCVendorLocations {
226
238
get {
227
- switch ( Application . platform ) {
228
- case RuntimePlatform . WindowsEditor :
229
- return "C:/Program Files/Autodesk" ;
230
- case RuntimePlatform . OSXEditor :
231
- return "/Applications/Autodesk" ;
232
- default :
233
- throw new NotImplementedException ( ) ;
239
+ var environmentVariable = Environment . GetEnvironmentVariable ( "UNITY_FBX_3DAPP_VENDOR_LOCATIONS" ) ;
240
+ if ( environmentVariable != null )
241
+ {
242
+ string [ ] locations = environmentVariable . Split ( ';' ) ;
243
+ List < string > locationsList = new List < string > ( ) ;
244
+ for ( int i = 0 ; i < locations . Length ; i ++ )
245
+ {
246
+ if ( Directory . Exists ( locations [ i ] ) )
247
+ {
248
+ locationsList . Add ( locations [ i ] ) ;
249
+ }
250
+ }
251
+ if ( locationsList . Count > 0 )
252
+ {
253
+ return locationsList . ToArray ( ) ;
254
+ }
255
+ }
256
+
257
+ switch ( Application . platform )
258
+ {
259
+ case RuntimePlatform . WindowsEditor :
260
+ return new string [ ] { "C:/Program Files/Autodesk" , "D:/Program Files/Autodesk" } ;
261
+ case RuntimePlatform . OSXEditor :
262
+ return new string [ ] { "/Applications/Autodesk" } ;
263
+ default :
264
+ throw new NotImplementedException ( ) ;
234
265
}
235
266
}
236
267
}
@@ -239,6 +270,7 @@ public static string kDefaultAdskRoot {
239
270
public bool mayaCompatibleNames ;
240
271
public bool centerObjects ;
241
272
public bool launchAfterInstallation ;
273
+ public int ExportFormatSelection ;
242
274
243
275
public int selectedDCCApp = 0 ;
244
276
@@ -267,6 +299,7 @@ protected override void LoadDefaults()
267
299
mayaCompatibleNames = true ;
268
300
centerObjects = true ;
269
301
launchAfterInstallation = true ;
302
+ ExportFormatSelection = 0 ;
270
303
convertToModelSavePath = kDefaultSavePath ;
271
304
dccOptionPaths = null ;
272
305
dccOptionNames = null ;
@@ -437,48 +470,67 @@ private static void FindDCCInstalls() {
437
470
var dccOptionName = instance . dccOptionNames ;
438
471
var dccOptionPath = instance . dccOptionPaths ;
439
472
440
- // If the location is given by the environment, use it.
441
- var location = System . Environment . GetEnvironmentVariable ( "MAYA_LOCATION" ) ;
442
- if ( ! string . IsNullOrEmpty ( location ) ) {
443
- location = location . TrimEnd ( '/' ) ;
444
- dccOptionPath . Add ( GetMayaExePath ( location . Replace ( "\\ " , "/" ) ) ) ;
445
- dccOptionName . Add ( "MAYA_LOCATION" ) ;
446
- }
447
-
448
- if ( ! Directory . Exists ( kDefaultAdskRoot ) ) {
449
- // no autodesk products installed
450
- return ;
451
- }
452
- // List that directory and find the right version:
453
- // either the newest version, or the exact version we wanted.
454
- var adskRoot = new System . IO . DirectoryInfo ( kDefaultAdskRoot ) ;
455
- foreach ( var productDir in adskRoot . GetDirectories ( ) ) {
456
- var product = productDir . Name ;
457
-
458
- // Only accept those that start with 'maya' in either case.
459
- if ( product . StartsWith ( "maya" , StringComparison . InvariantCultureIgnoreCase ) ) {
460
- string version = product . Substring ( "maya" . Length ) ;
461
- dccOptionPath . Add ( GetMayaExePath ( productDir . FullName . Replace ( "\\ " , "/" ) ) ) ;
462
- dccOptionName . Add ( GetUniqueDCCOptionName ( kMayaOptionName + version ) ) ;
473
+ for ( int i = 0 ; i < DCCVendorLocations . Length ; i ++ )
474
+ {
475
+ if ( ! Directory . Exists ( DCCVendorLocations [ i ] ) )
476
+ {
477
+ // no autodesk products installed
478
+ continue ;
463
479
}
480
+ // List that directory and find the right version:
481
+ // either the newest version, or the exact version we wanted.
482
+ var adskRoot = new System . IO . DirectoryInfo ( DCCVendorLocations [ i ] ) ;
483
+ foreach ( var productDir in adskRoot . GetDirectories ( ) )
484
+ {
485
+ var product = productDir . Name ;
486
+
487
+ // Only accept those that start with 'maya' in either case.
488
+ if ( product . StartsWith ( "maya" , StringComparison . InvariantCultureIgnoreCase ) ) {
489
+ string version = product . Substring ( "maya" . Length ) ;
490
+ dccOptionPath . Add ( GetMayaExePath ( productDir . FullName . Replace ( "\\ " , "/" ) ) ) ;
491
+ dccOptionName . Add ( GetUniqueDCCOptionName ( kMayaOptionName + version ) ) ;
492
+ continue ;
493
+ }
464
494
465
- if ( product . StartsWith ( "3ds max" , StringComparison . InvariantCultureIgnoreCase ) ) {
466
- var exePath = string . Format ( "{0}/{1}" , productDir . FullName . Replace ( "\\ " , "/" ) , "3dsmax.exe" ) ;
495
+ if ( product . StartsWith ( "3ds max" , StringComparison . InvariantCultureIgnoreCase ) )
496
+ {
497
+ var exePath = string . Format ( "{0}/{1}" , productDir . FullName . Replace ( "\\ " , "/" ) , "3dsmax.exe" ) ;
467
498
468
- string version = product . Substring ( "3ds max " . Length ) ;
469
- var maxOptionName = GetUniqueDCCOptionName ( kMaxOptionName + version ) ;
499
+ string version = product . Substring ( "3ds max " . Length ) ;
500
+ var maxOptionName = GetUniqueDCCOptionName ( kMaxOptionName + version ) ;
470
501
471
- if ( IsEarlierThanMax2017 ( maxOptionName ) ) {
472
- continue ;
502
+ if ( IsEarlierThanMax2017 ( maxOptionName ) )
503
+ {
504
+ continue ;
505
+ }
506
+
507
+ dccOptionPath . Add ( exePath ) ;
508
+ dccOptionName . Add ( maxOptionName ) ;
473
509
}
474
-
475
- dccOptionPath . Add ( exePath ) ;
476
- dccOptionName . Add ( maxOptionName ) ;
477
510
}
478
511
}
479
512
instance . selectedDCCApp = instance . GetPreferredDCCApp ( ) ;
480
513
}
481
514
515
+ /// <summary>
516
+ /// Returns the first valid folder in our list of vendor locations
517
+ /// </summary>
518
+ /// <returns>The first valid vendor location</returns>
519
+ public static string GetFirstValidVendorLocation ( )
520
+ {
521
+ string [ ] locations = DCCVendorLocations ;
522
+ for ( int i = 0 ; i < locations . Length ; i ++ )
523
+ {
524
+ //Look through the list of locations we have and take the first valid one
525
+ if ( Directory . Exists ( locations [ i ] ) )
526
+ {
527
+ return locations [ i ] ;
528
+ }
529
+ }
530
+ //if no valid locations exist, just take us to the project folder
531
+ return Directory . GetCurrentDirectory ( ) ;
532
+ }
533
+
482
534
/// <summary>
483
535
/// Gets the maya exe at Maya install location.
484
536
/// </summary>
@@ -537,6 +589,7 @@ public static GUIContent[] GetDCCOptions(){
537
589
}
538
590
539
591
if ( instance . dccOptionPaths . Count <= 0 ) {
592
+ instance . selectedDCCApp = 0 ;
540
593
return new GUIContent [ ] {
541
594
new GUIContent ( "<No 3D Application found>" )
542
595
} ;
0 commit comments