Skip to content

Commit 8660f1e

Browse files
author
AJubrey
committed
[ADDED] a check box below the installation button to allow the user to have their program launch automatically after installation
1 parent 283951d commit 8660f1e

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ public override void OnInspectorGUI() {
167167
FbxExporters.Editor.IntegrationsUI.InstallDCCIntegration ();
168168
}
169169

170+
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
171+
new GUIContent("Launch program after installation:",
172+
"Launch the selected application after unity integration is completed."),
173+
exportSettings.launchAfterInstallation
174+
);
175+
170176
GUILayout.FlexibleSpace ();
171177
GUILayout.EndScrollView ();
172178

@@ -246,6 +252,7 @@ public static string kDefaultAdskRoot {
246252
// Note: default values are set in LoadDefaults().
247253
public bool mayaCompatibleNames;
248254
public bool centerObjects;
255+
public bool launchAfterInstallation;
249256

250257
public int selectedDCCApp = 0;
251258

@@ -273,6 +280,7 @@ protected override void LoadDefaults()
273280
{
274281
mayaCompatibleNames = true;
275282
centerObjects = true;
283+
launchAfterInstallation = true;
276284
convertToModelSavePath = kDefaultSavePath;
277285
dccOptionPaths = null;
278286
dccOptionNames = null;

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,12 @@ public static int ConfigureMaya(string mayaPath)
324324
ExitCode = myProcess.ExitCode;
325325
Debug.Log(string.Format("Ran maya: [{0}]\nWith args [{1}]\nResult {2}",
326326
mayaPath, myProcess.StartInfo.Arguments, ExitCode));
327-
}
327+
328+
if (EditorTools.ExportSettings.instance.launchAfterInstallation)
329+
{
330+
LaunchMaya(mayaPath);
331+
}
332+
}
328333
catch (Exception e)
329334
{
330335
UnityEngine.Debug.LogError(string.Format ("Exception failed to start Maya ({0})", e.Message));
@@ -333,6 +338,18 @@ public static int ConfigureMaya(string mayaPath)
333338
return ExitCode;
334339
}
335340

341+
public static void LaunchMaya(string mayaPath)
342+
{
343+
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
344+
myProcess.StartInfo.FileName = mayaPath;
345+
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
346+
myProcess.StartInfo.CreateNoWindow = false;
347+
myProcess.StartInfo.UseShellExecute = false;
348+
349+
myProcess.EnableRaisingEvents = false;
350+
myProcess.Start();
351+
}
352+
336353
public static bool InstallMaya(bool verbose = false)
337354
{
338355
// What's happening here is that we copy the module template to
@@ -532,8 +549,13 @@ public static int InstallMaxPlugin(string maxExe){
532549
myProcess.WaitForExit();
533550
ExitCode = myProcess.ExitCode;
534551

552+
if (EditorTools.ExportSettings.instance.launchAfterInstallation)
553+
{
554+
LaunchMax(maxExe);
555+
}
556+
535557
// TODO (UNI-29910): figure out what exactly causes this exit code + how to resolve
536-
if(ExitCode == -1073740791){
558+
if (ExitCode == -1073740791){
537559
Debug.Log(string.Format("Detected 3ds max exitcode {0} -- safe to ignore", ExitCode));
538560
ExitCode = 0;
539561
}
@@ -545,10 +567,22 @@ public static int InstallMaxPlugin(string maxExe){
545567
{
546568
UnityEngine.Debug.LogError(string.Format ("Exception failed to start Max ({0})", e.Message));
547569
ExitCode = -1;
548-
}
570+
}
549571
return ExitCode;
550572
}
551573

574+
public static void LaunchMax(string maxPath)
575+
{
576+
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
577+
myProcess.StartInfo.FileName = maxPath;
578+
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
579+
myProcess.StartInfo.CreateNoWindow = false;
580+
myProcess.StartInfo.UseShellExecute = false;
581+
582+
myProcess.EnableRaisingEvents = false;
583+
myProcess.Start();
584+
}
585+
552586
public override int InstallIntegration(string maxExe){
553587
return MaxIntegration.InstallMaxPlugin (maxExe);
554588
}

0 commit comments

Comments
 (0)