@@ -63,6 +63,22 @@ public static string GetProjectPath()
63
63
/// <returns><c>true</c> if folder is already unzipped at the specified path; otherwise, <c>false</c>.</returns>
64
64
/// <param name="path">Path.</param>
65
65
public abstract bool FolderAlreadyUnzippedAtPath ( string path ) ;
66
+
67
+ /// <summary>
68
+ /// Launches application at given path
69
+ /// </summary>
70
+ /// <param name="AppPath"></param>
71
+ public static void LaunchDCCApplication ( string AppPath )
72
+ {
73
+ System . Diagnostics . Process myProcess = new System . Diagnostics . Process ( ) ;
74
+ myProcess . StartInfo . FileName = AppPath ;
75
+ myProcess . StartInfo . WindowStyle = System . Diagnostics . ProcessWindowStyle . Normal ;
76
+ myProcess . StartInfo . CreateNoWindow = false ;
77
+ myProcess . StartInfo . UseShellExecute = false ;
78
+
79
+ myProcess . EnableRaisingEvents = false ;
80
+ myProcess . Start ( ) ;
81
+ }
66
82
}
67
83
68
84
@@ -117,10 +133,14 @@ private static string ESCAPED_QUOTE {
117
133
}
118
134
}
119
135
120
- private static string MAYA_COMMANDS { get {
121
- return string . Format ( "configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6}; scriptJob -idleEvent quit; " ,
136
+ private static string MAYA_CONFIG_COMMAND { get {
137
+ return string . Format ( "configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6};" ,
122
138
ESCAPED_QUOTE , GetProjectPath ( ) , GetAppPath ( ) , GetTempSavePath ( ) ,
123
- GetExportSettingsPath ( ) , GetMayaInstructionPath ( ) , ( IsHeadlessInstall ( ) ? 1 : 0 ) ) ;
139
+ GetExportSettingsPath ( ) , GetMayaInstructionPath ( ) , ( IsHeadlessInstall ( ) ? 1 : 0 ) ) ;
140
+ } }
141
+
142
+ private static string MAYA_CLOSE_COMMAND { get {
143
+ return string . Format ( "scriptJob -idleEvent quit;" ) ;
124
144
} }
125
145
private static Char [ ] FIELD_SEPARATORS = new Char [ ] { ':' } ;
126
146
@@ -307,24 +327,45 @@ public static int ConfigureMaya(string mayaPath)
307
327
myProcess . StartInfo . CreateNoWindow = true ;
308
328
myProcess . StartInfo . UseShellExecute = false ;
309
329
330
+ string commandString ;
331
+
310
332
switch ( Application . platform ) {
311
333
case RuntimePlatform . WindowsEditor :
312
- myProcess . StartInfo . Arguments = string . Format ( "-command \" {0}\" " , MAYA_COMMANDS ) ;
334
+ commandString = "-command \" {0}\" " ;
313
335
break ;
314
336
case RuntimePlatform . OSXEditor :
315
- myProcess . StartInfo . Arguments = string . Format ( @"-command '{0}'" , MAYA_COMMANDS ) ;
337
+ commandString = @"-command '{0}'" ;
316
338
break ;
317
339
default :
318
340
throw new NotImplementedException ( ) ;
319
341
}
320
342
343
+ if ( EditorTools . ExportSettings . instance . launchAfterInstallation )
344
+ {
345
+ myProcess . StartInfo . WindowStyle = System . Diagnostics . ProcessWindowStyle . Normal ;
346
+ myProcess . StartInfo . CreateNoWindow = false ;
347
+ myProcess . StartInfo . Arguments = string . Format ( commandString , MAYA_CONFIG_COMMAND ) ;
348
+ }
349
+ else
350
+ {
351
+ myProcess . StartInfo . Arguments = string . Format ( commandString , MAYA_CONFIG_COMMAND + MAYA_CLOSE_COMMAND ) ;
352
+ }
353
+
321
354
myProcess . EnableRaisingEvents = true ;
322
355
myProcess . Start ( ) ;
323
- myProcess . WaitForExit ( ) ;
324
- ExitCode = myProcess . ExitCode ;
325
- Debug . Log ( string . Format ( "Ran maya: [{0}]\n With args [{1}]\n Result {2}" ,
326
- mayaPath , myProcess . StartInfo . Arguments , ExitCode ) ) ;
327
- }
356
+
357
+ if ( ! EditorTools . ExportSettings . instance . launchAfterInstallation )
358
+ {
359
+ myProcess . WaitForExit ( ) ;
360
+ ExitCode = myProcess . ExitCode ;
361
+ Debug . Log ( string . Format ( "Ran maya: [{0}]\n With args [{1}]\n Result {2}" ,
362
+ mayaPath , myProcess . StartInfo . Arguments , ExitCode ) ) ;
363
+ }
364
+ else
365
+ {
366
+ ExitCode = 0 ;
367
+ }
368
+ }
328
369
catch ( Exception e )
329
370
{
330
371
UnityEngine . Debug . LogError ( string . Format ( "Exception failed to start Maya ({0})" , e . Message ) ) ;
@@ -532,8 +573,13 @@ public static int InstallMaxPlugin(string maxExe){
532
573
myProcess . WaitForExit ( ) ;
533
574
ExitCode = myProcess . ExitCode ;
534
575
576
+ if ( EditorTools . ExportSettings . instance . launchAfterInstallation )
577
+ {
578
+ LaunchDCCApplication ( maxExe ) ;
579
+ }
580
+
535
581
// TODO (UNI-29910): figure out what exactly causes this exit code + how to resolve
536
- if ( ExitCode == - 1073740791 ) {
582
+ if ( ExitCode == - 1073740791 ) {
537
583
Debug . Log ( string . Format ( "Detected 3ds max exitcode {0} -- safe to ignore" , ExitCode ) ) ;
538
584
ExitCode = 0 ;
539
585
}
@@ -545,7 +591,7 @@ public static int InstallMaxPlugin(string maxExe){
545
591
{
546
592
UnityEngine . Debug . LogError ( string . Format ( "Exception failed to start Max ({0})" , e . Message ) ) ;
547
593
ExitCode = - 1 ;
548
- }
594
+ }
549
595
return ExitCode ;
550
596
}
551
597
0 commit comments