Skip to content

Commit f9cf564

Browse files
committed
handle unity 6000 different simplewebserver args, fixes #165
1 parent 5954f47 commit f9cf564

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

UnityLauncherPro/Tools.cs

+32-2
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,21 @@ public static void LaunchWebGL(Project proj, string relativeFolder)
20082008
// take process id from unity, if have it (then webserver closes automatically when unity is closed)
20092009
var proc = ProcessHandler.Get(proj.Path);
20102010
int pid = proc == null ? -1 : proc.Id;
2011-
var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
2011+
string param = null;
2012+
2013+
// parse proj version year as number 2019.4.1f1 -> 2019
2014+
int year = 0;
2015+
var versionParts = proj.Version.Split('.');
2016+
bool parsedYear = int.TryParse(versionParts[0], out year);
2017+
2018+
if (parsedYear && year >= 6000)
2019+
{
2020+
param = "\"" + webExe + "\" \"" + buildPath + "\" " + "http://localhost:" + port + "/" + (pid == -1 ? "" : " " + pid);
2021+
}
2022+
else // older versions or failed to parse
2023+
{
2024+
param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
2025+
}
20122026

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

@@ -2068,7 +2082,23 @@ public static void LaunchWebGL(Project proj, string relativeFolder)
20682082
// take process id from unity, if have it(then webserver closes automatically when unity is closed)
20692083
var proc = ProcessHandler.Get(proj.Path);
20702084
int pid = proc == null ? -1 : proc.Id;
2071-
var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
2085+
2086+
// parse proj version year as number 2019.4.1f1 -> 2019
2087+
string param = null;
2088+
int year = 0;
2089+
var versionParts = proj.Version.Split('.');
2090+
bool parsedYear = int.TryParse(versionParts[0], out year);
2091+
2092+
if (parsedYear && year >= 6000)
2093+
{
2094+
param = "\"" + webExe + "\" \"" + buildPath + "\" " + "\"http://localhost:" + port + "/\"" + (pid == -1 ? "" : " " + pid);
2095+
}
2096+
else // older versions or failed to parse
2097+
{
2098+
param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
2099+
}
2100+
2101+
//var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port
20722102

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

0 commit comments

Comments
 (0)