Skip to content

Commit

Permalink
handle unity 6000 different simplewebserver args, fixes #165
Browse files Browse the repository at this point in the history
  • Loading branch information
unitycoder committed Sep 22, 2024
1 parent 5954f47 commit f9cf564
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions UnityLauncherPro/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,21 @@ public static void LaunchWebGL(Project proj, string relativeFolder)
// take process id from unity, if have it (then webserver closes automatically when unity is closed)
var proc = ProcessHandler.Get(proj.Path);
int pid = proc == null ? -1 : proc.Id;
var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
string param = null;

// parse proj version year as number 2019.4.1f1 -> 2019
int year = 0;
var versionParts = proj.Version.Split('.');
bool parsedYear = int.TryParse(versionParts[0], out year);

if (parsedYear && year >= 6000)
{
param = "\"" + webExe + "\" \"" + buildPath + "\" " + "http://localhost:" + port + "/" + (pid == -1 ? "" : " " + pid);
}
else // older versions or failed to parse
{
param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
}

var webglServerProcess = Tools.LaunchExe(monoExe, param);

Expand Down Expand Up @@ -2068,7 +2082,23 @@ public static void LaunchWebGL(Project proj, string relativeFolder)
// take process id from unity, if have it(then webserver closes automatically when unity is closed)
var proc = ProcessHandler.Get(proj.Path);
int pid = proc == null ? -1 : proc.Id;
var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port

// parse proj version year as number 2019.4.1f1 -> 2019
string param = null;
int year = 0;
var versionParts = proj.Version.Split('.');
bool parsedYear = int.TryParse(versionParts[0], out year);

if (parsedYear && year >= 6000)
{
param = "\"" + webExe + "\" \"" + buildPath + "\" " + "\"http://localhost:" + port + "/\"" + (pid == -1 ? "" : " " + pid);
}
else // older versions or failed to parse
{
param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
}

//var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port

var webglServerProcess = Tools.LaunchExe(monoExe, param);

Expand Down

0 comments on commit f9cf564

Please sign in to comment.