@@ -31,15 +31,15 @@ public MayaException(string message) : base(message) { }
31
31
public MayaException ( string message , System . Exception inner ) : base ( message , inner ) { }
32
32
}
33
33
34
- public class MayaVersion {
34
+ public class MayaLocation {
35
35
36
36
/// <summary>
37
37
/// Find the Maya installation that has your desired version, or
38
38
/// the newest version if the 'desired' is an empty string.
39
39
///
40
40
/// If MAYA_LOCATION is set, the desired version is ignored.
41
41
/// </summary>
42
- public MayaVersion ( string desiredVersion = "" ) {
42
+ public MayaLocation ( string desiredVersion = "" ) {
43
43
// If the location is given by the environment, use it.
44
44
Location = System . Environment . GetEnvironmentVariable ( "MAYA_LOCATION" ) ;
45
45
if ( ! string . IsNullOrEmpty ( Location ) ) {
@@ -136,45 +136,6 @@ public string MayaExe {
136
136
#endif
137
137
}
138
138
}
139
-
140
- /// <summary>
141
- /// The version number.
142
- ///
143
- /// This may involve running Maya so it can be expensive (a few
144
- /// seconds).
145
- /// </summary>
146
- public string Version {
147
- get {
148
- if ( string . IsNullOrEmpty ( m_version ) ) {
149
- m_version = AskVersion ( MayaExe ) ;
150
- }
151
- return m_version ;
152
- }
153
- }
154
- string m_version ;
155
-
156
- /// <summary>
157
- /// Ask the version number by running maya.
158
- /// </summary>
159
- static string AskVersion ( string exePath ) {
160
- System . Diagnostics . Process myProcess = new System . Diagnostics . Process ( ) ;
161
- myProcess . StartInfo . FileName = exePath ;
162
- myProcess . StartInfo . WindowStyle = System . Diagnostics . ProcessWindowStyle . Hidden ;
163
- myProcess . StartInfo . CreateNoWindow = true ;
164
- myProcess . StartInfo . UseShellExecute = false ;
165
- myProcess . StartInfo . RedirectStandardOutput = true ;
166
- myProcess . StartInfo . Arguments = "-v" ;
167
- myProcess . EnableRaisingEvents = true ;
168
- myProcess . Start ( ) ;
169
- string resultString = myProcess . StandardOutput . ReadToEnd ( ) ;
170
- myProcess . WaitForExit ( ) ;
171
-
172
- // Output is like: Maya 2018, Cut Number 201706261615
173
- // We want the stuff after 'Maya ' and before the comma.
174
- // TODO: less brittle! Consider also the mel command "about -version".
175
- var commaIndex = resultString . IndexOf ( ',' ) ;
176
- return resultString . Substring ( 0 , commaIndex ) . Substring ( "Maya " . Length ) ;
177
- }
178
139
} ;
179
140
180
141
// Use string to define escaped quote
@@ -205,12 +166,12 @@ public static bool IsHeadlessInstall ()
205
166
return false ;
206
167
}
207
168
208
- public static string GetModulePath ( string version )
169
+ public static string GetModulePath ( )
209
170
{
210
171
return System . IO . Path . Combine ( GetUserFolder ( ) , MAYA_MODULES_PATH ) ;
211
172
}
212
173
213
- public static string GetModuleTemplatePath ( string version )
174
+ public static string GetModuleTemplatePath ( )
214
175
{
215
176
return System . IO . Path . Combine ( Application . dataPath , MODULE_TEMPLATE_PATH ) ;
216
177
}
@@ -340,12 +301,12 @@ private static void WriteFile(string FileName, List<string> Lines )
340
301
}
341
302
}
342
303
343
- public static int ConfigureMaya ( MayaVersion version )
304
+ public static int ConfigureMaya ( MayaLocation mayaLoc )
344
305
{
345
306
int ExitCode = 0 ;
346
307
347
308
try {
348
- string mayaPath = version . MayaExe ;
309
+ string mayaPath = mayaLoc . MayaExe ;
349
310
if ( ! System . IO . File . Exists ( mayaPath ) )
350
311
{
351
312
Debug . LogError ( string . Format ( "No maya installation found at {0}" , mayaPath ) ) ;
@@ -380,27 +341,24 @@ public static int ConfigureMaya(MayaVersion version)
380
341
return ExitCode ;
381
342
}
382
343
383
- public static bool InstallMaya ( MayaVersion version = null , bool verbose = false )
344
+ public static bool InstallMaya ( bool verbose = false )
384
345
{
385
346
// What's happening here is that we copy the module template to
386
347
// the module path, basically:
387
348
// - copy the template to the user Maya module path
388
349
// - search-and-replace its tags
389
350
// - done.
390
351
// But it's complicated because we can't trust any files actually exist.
391
- if ( version == null ) {
392
- version = new MayaVersion ( ) ;
393
- }
394
352
395
- string moduleTemplatePath = GetModuleTemplatePath ( version . Version ) ;
353
+ string moduleTemplatePath = GetModuleTemplatePath ( ) ;
396
354
if ( ! System . IO . File . Exists ( moduleTemplatePath ) )
397
355
{
398
- Debug . LogError ( string . Format ( "FbxExporters package doesn't have support for " + version . Version ) ) ;
356
+ Debug . LogError ( string . Format ( "Missing Maya module file" ) ) ;
399
357
return false ;
400
358
}
401
359
402
360
// Create the {USER} modules folder and empty it so it's ready to set up.
403
- string modulePath = GetModulePath ( version . Version ) ;
361
+ string modulePath = GetModulePath ( ) ;
404
362
string moduleFilePath = System . IO . Path . Combine ( modulePath , MODULE_FILENAME + ".mod" ) ;
405
363
bool installed = false ;
406
364
@@ -486,20 +444,20 @@ class IntegrationsUI
486
444
{
487
445
public static void InstallMayaIntegration ( )
488
446
{
489
- var mayaVersion = new Integrations . MayaVersion ( ) ;
490
- if ( ! Integrations . InstallMaya ( mayaVersion , verbose : true ) ) {
447
+ if ( ! Integrations . InstallMaya ( verbose : true ) ) {
491
448
return ;
492
449
}
493
450
494
- int exitCode = Integrations . ConfigureMaya ( mayaVersion ) ;
451
+ var mayaLoc = new Integrations . MayaLocation ( ) ;
452
+ int exitCode = Integrations . ConfigureMaya ( mayaLoc ) ;
495
453
496
454
string title , message ;
497
455
if ( exitCode != 0 ) {
498
- title = string . Format ( "Failed to install Maya {0} Integration." , mayaVersion . Version ) ;
456
+ title = "Failed to install Maya Integration." ;
499
457
message = string . Format ( "Failed to configure Maya, please check logs (exitcode={0})." , exitCode ) ;
500
458
} else {
501
- title = string . Format ( "Completed installation of Maya {0} Integration." , mayaVersion . Version ) ;
502
- message = string . Format ( "Enjoy the new \" Unity\" menu in Maya {0}." , mayaVersion . Version ) ;
459
+ title = "Completed installation of Maya Integration." ;
460
+ message = "Enjoy the new \" Unity\" menu in Maya." ;
503
461
}
504
462
UnityEditor . EditorUtility . DisplayDialog ( title , message , "Ok" ) ;
505
463
}
0 commit comments