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

Commit

Permalink
pass all arguments to launcher when running from commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
unitycoder committed Feb 17, 2018
1 parent 3591453 commit e51c815
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions UnityLauncher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,34 @@ void Start()
string[] args = Environment.GetCommandLineArgs();
if (args != null && args.Length > 2)
{
// first argument needs to be -projectPath
var commandLineArgs = args[1];
if (commandLineArgs == "-projectPath")
{
SetStatus("Launching from commandline..");

// path
var projectPathArgument = args[2];

var version = Tools.GetProjectVersion(projectPathArgument);

// try launching it
LaunchProject(projectPathArgument, version, true);
// take extra arguments also
var commandLineArguments = "";
for (int i = 3, len = args.Length; i < len; i++)
{
commandLineArguments += " " + args[i];
}

SetStatus("Ready");
// try launching it
LaunchProject(projectPathArgument, version, openProject: true, commandLineArguments: commandLineArguments);

// quit after launch if enabled in settings
if (Properties.Settings.Default.closeAfterExplorer == true)
{
Application.Exit();
}

SetStatus("Ready");
}
else
{
Expand Down Expand Up @@ -329,7 +339,7 @@ void UpdateRecentProjectsList()
SetStatus("Ready");
}

void LaunchProject(string projectPath, string version, bool openProject = true)
void LaunchProject(string projectPath, string version, bool openProject = true, string commandLineArguments = "")
{
if (Directory.Exists(projectPath) == true)
{
Expand Down Expand Up @@ -372,7 +382,7 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
pars += " " + customArguments;
}

myProcess.StartInfo.Arguments = pars;
myProcess.StartInfo.Arguments = pars + commandLineArguments;
}
myProcess.Start();

Expand Down

0 comments on commit e51c815

Please sign in to comment.