Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.

Commit e51c815

Browse files
committed
pass all arguments to launcher when running from commandline
1 parent 3591453 commit e51c815

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: UnityLauncher/Form1.cs

+15-5
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,34 @@ void Start()
6464
string[] args = Environment.GetCommandLineArgs();
6565
if (args != null && args.Length > 2)
6666
{
67+
// first argument needs to be -projectPath
6768
var commandLineArgs = args[1];
6869
if (commandLineArgs == "-projectPath")
6970
{
7071
SetStatus("Launching from commandline..");
7172

73+
// path
7274
var projectPathArgument = args[2];
75+
7376
var version = Tools.GetProjectVersion(projectPathArgument);
7477

75-
// try launching it
76-
LaunchProject(projectPathArgument, version, true);
78+
// take extra arguments also
79+
var commandLineArguments = "";
80+
for (int i = 3, len = args.Length; i < len; i++)
81+
{
82+
commandLineArguments += " " + args[i];
83+
}
7784

78-
SetStatus("Ready");
85+
// try launching it
86+
LaunchProject(projectPathArgument, version, openProject: true, commandLineArguments: commandLineArguments);
7987

8088
// quit after launch if enabled in settings
8189
if (Properties.Settings.Default.closeAfterExplorer == true)
8290
{
8391
Application.Exit();
8492
}
93+
94+
SetStatus("Ready");
8595
}
8696
else
8797
{
@@ -329,7 +339,7 @@ void UpdateRecentProjectsList()
329339
SetStatus("Ready");
330340
}
331341

332-
void LaunchProject(string projectPath, string version, bool openProject = true)
342+
void LaunchProject(string projectPath, string version, bool openProject = true, string commandLineArguments = "")
333343
{
334344
if (Directory.Exists(projectPath) == true)
335345
{
@@ -372,7 +382,7 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
372382
pars += " " + customArguments;
373383
}
374384

375-
myProcess.StartInfo.Arguments = pars;
385+
myProcess.StartInfo.Arguments = pars + commandLineArguments;
376386
}
377387
myProcess.Start();
378388

0 commit comments

Comments
 (0)