@@ -200,13 +200,49 @@ protected override void LoadDefaults()
200
200
mayaAppOptions = null ;
201
201
}
202
202
203
+ /// <summary>
204
+ /// Find Maya installations at default install path.
205
+ /// Add results to given dictionary.
206
+ ///
207
+ /// If MAYA_LOCATION is set, add this to the list as well.
208
+ /// </summary>
209
+ private static System . Collections . Generic . Dictionary < string , string > FindMayaInstalls ( ) {
210
+ System . Collections . Generic . Dictionary < string , string > mayaAppOptions =
211
+ new System . Collections . Generic . Dictionary < string , string > ( ) ;
212
+
213
+ // If the location is given by the environment, use it.
214
+ var location = System . Environment . GetEnvironmentVariable ( "MAYA_LOCATION" ) ;
215
+ if ( ! string . IsNullOrEmpty ( location ) ) {
216
+ location = location . TrimEnd ( '/' ) ;
217
+ mayaAppOptions . Add ( location , "MAYA_LOCATION" ) ;
218
+ }
219
+
220
+ // List that directory and find the right version:
221
+ // either the newest version, or the exact version we wanted.
222
+ var adskRoot = new System . IO . DirectoryInfo ( kDefaultAdskRoot ) ;
223
+ foreach ( var productDir in adskRoot . GetDirectories ( ) ) {
224
+ var product = productDir . Name ;
225
+
226
+ // Only accept those that start with 'maya' in either case.
227
+ if ( ! product . StartsWith ( "maya" , StringComparison . InvariantCultureIgnoreCase ) ) {
228
+ continue ;
229
+ }
230
+ // Reject MayaLT -- it doesn't have plugins.
231
+ if ( product . StartsWith ( "mayalt" , StringComparison . InvariantCultureIgnoreCase ) ) {
232
+ continue ;
233
+ }
234
+ mayaAppOptions . Add ( productDir . FullName , product ) ;
235
+ }
236
+ return mayaAppOptions ;
237
+ }
238
+
203
239
public static GUIContent [ ] GetMayaOptions ( ) {
204
240
if ( instance . mayaAppOptions == null ) {
205
- instance . mayaAppOptions = new System . Collections . Generic . Dictionary < string , string > ( ) ;
206
- instance . mayaAppOptions . Add ( "c:/" , "Maya2017" ) ;
207
- instance . mayaAppOptions . Add ( "d:/" , "Maya2018" ) ;
208
-
209
- instance . mayaOptionPaths = new System . Collections . Generic . List < string > ( ) { "c:/" , "d:/" } ;
241
+ instance . mayaAppOptions = FindMayaInstalls ( ) ;
242
+ instance . mayaOptionPaths = new System . Collections . Generic . List < string > ( ) ;
243
+ foreach ( var key in instance . mayaAppOptions . Keys ) {
244
+ instance . mayaOptionPaths . Add ( key ) ;
245
+ }
210
246
}
211
247
GUIContent [ ] optionArray = new GUIContent [ instance . mayaAppOptions . Count + 1 ] ;
212
248
for ( int i = 0 ; i < instance . mayaOptionPaths . Count ; i ++ ) {
0 commit comments