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

Commit 726fe87

Browse files
authored
Add files via upload
1 parent 5e08a5b commit 726fe87

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

‎UnityLauncher/Form1.cs

+23-16
Original file line numberDiff line numberDiff line change
@@ -530,24 +530,31 @@ bool CheckCrashBackupScene(string projectPath)
530530

531531
// parse Unity installer exe from release page
532532
// thanks to https://github.com/softfruit
533-
string GetDownloadUrlForUnityVersion(string releaseUrl)
533+
string GetDownloadUrlForUnityVersion(string version)
534534
{
535535
string url = "";
536-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
537-
using (WebClient client = new WebClient())
538-
{
539-
string html = client.DownloadString(releaseUrl);
540-
Regex regex = new Regex(@"(http).+(UnityDownloadAssistant)+[^\s*]*(.exe)");
541-
Match match = regex.Match(html);
542-
if (match.Success == true)
543-
{
544-
url = match.Groups[0].Captures[0].Value;
545-
}
546-
else
547-
{
548-
SetStatus("Cannot find UnityDownloadAssistant.exe for this version.");
549-
}
536+
537+
using (WebClient client = new WebClient())
538+
{
539+
string htmlCode = client.DownloadString("https://unity3d.com/get-unity/download/archive");
540+
string[] lines = htmlCode.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
541+
542+
for (int i = 0; i < lines.Length; i++)
543+
{
544+
if (lines[i].Contains("UnitySetup64-" + version))
545+
{
546+
string line = lines[i-1];
547+
int start = line.IndexOf('"') + 1;
548+
int end = line.IndexOf('"', start);
549+
url = @"https://unity3d.com" + line.Substring(start, end - start);
550+
break;
551+
}
552+
}
550553
}
554+
555+
if(string.IsNullOrEmpty(url))
556+
SetStatus("Cannot find UnityDownloadAssistant.exe for this version.");
557+
551558
return url;
552559
}
553560

@@ -557,7 +564,7 @@ string GetDownloadUrlForUnityVersion(string releaseUrl)
557564
/// <param name="url">full url to installer</param>
558565
void DownloadInBrowser(string url, string version)
559566
{
560-
string exeURL = GetDownloadUrlForUnityVersion(url);
567+
string exeURL = GetDownloadUrlForUnityVersion(version);
561568
if (string.IsNullOrEmpty(exeURL) == false)
562569
{
563570
SetStatus("Download installer in browser: " + exeURL);

0 commit comments

Comments
 (0)