@@ -264,14 +264,14 @@ private static string GetMayaLocationFromEnvironmentVariable(string env)
264
264
if ( string . IsNullOrEmpty ( location ) )
265
265
return null ;
266
266
267
- if ( ! Directory . Exists ( location ) )
268
- return null ;
269
-
270
267
//Remove any extra slashes on the end
271
268
//Maya would accept a single slash in either direction, so we should be able to
272
269
location = location . Replace ( "\\ " , "/" ) ;
273
270
location = location . TrimEnd ( '/' ) ;
274
271
272
+ if ( ! Directory . Exists ( location ) )
273
+ return null ;
274
+
275
275
if ( Application . platform == RuntimePlatform . WindowsEditor )
276
276
{
277
277
//If we are on Windows, we need only go up one location to get to the "Autodesk" folder.
@@ -327,9 +327,32 @@ private static HashSet<string> GetCustomVendorLocations()
327
327
private static HashSet < string > GetDefaultVendorLocations ( )
328
328
{
329
329
if ( Application . platform == RuntimePlatform . WindowsEditor )
330
- return new HashSet < string > ( ) { "C:/Program Files/Autodesk" , "D:/Program Files/Autodesk" } ;
330
+ {
331
+ HashSet < string > windowsDefaults = new HashSet < string > ( ) { "C:/Program Files/Autodesk" , "D:/Program Files/Autodesk" } ;
332
+ HashSet < string > existingDirectories = new HashSet < string > ( ) ;
333
+ foreach ( string path in windowsDefaults )
334
+ {
335
+ if ( Directory . Exists ( path ) )
336
+ {
337
+ existingDirectories . Add ( path ) ;
338
+ }
339
+ }
340
+ return existingDirectories ;
341
+
342
+ }
331
343
else if ( Application . platform == RuntimePlatform . OSXEditor )
332
- return new HashSet < string > ( ) { "/Applications/Autodesk" } ;
344
+ {
345
+ HashSet < string > MacOSDefaults = new HashSet < string > ( ) { "/Applications/Autodesk" } ;
346
+ HashSet < string > existingDirectories = new HashSet < string > ( ) ;
347
+ foreach ( string path in MacOSDefaults )
348
+ {
349
+ if ( Directory . Exists ( path ) )
350
+ {
351
+ existingDirectories . Add ( path ) ;
352
+ }
353
+ }
354
+ return existingDirectories ;
355
+ }
333
356
334
357
throw new NotImplementedException ( ) ;
335
358
}
@@ -807,10 +830,18 @@ static string AskMayaVersion(string exePath) {
807
830
// Output is like: Maya 2018, Cut Number 201706261615
808
831
// We want the stuff after 'Maya ' and before the comma.
809
832
// (Uni-31601) less brittle! Consider also the mel command "about -version".
833
+ if ( string . IsNullOrEmpty ( resultString ) )
834
+ {
835
+ return null ;
836
+ }
837
+
838
+ resultString = resultString . Trim ( ) ;
810
839
var commaIndex = resultString . IndexOf ( ',' ) ;
811
- if ( ! string . IsNullOrEmpty ( resultString . Trim ( ) ) )
840
+
841
+ if ( commaIndex != - 1 )
812
842
{
813
- return resultString . Substring ( 0 , commaIndex ) . Substring ( "Maya " . Length ) ;
843
+ const int versionStart = 5 ; // length of "Maya "
844
+ return resultString . Length > versionStart ? resultString . Substring ( 0 , commaIndex ) . Substring ( versionStart ) : null ;
814
845
}
815
846
else
816
847
{
0 commit comments