@@ -530,24 +530,31 @@ bool CheckCrashBackupScene(string projectPath)
530
530
531
531
// parse Unity installer exe from release page
532
532
// thanks to https://github.com/softfruit
533
- string GetDownloadUrlForUnityVersion ( string releaseUrl )
533
+ string GetDownloadUrlForUnityVersion ( string version )
534
534
{
535
535
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
+ }
550
553
}
554
+
555
+ if ( string . IsNullOrEmpty ( url ) )
556
+ SetStatus ( "Cannot find UnityDownloadAssistant.exe for this version." ) ;
557
+
551
558
return url ;
552
559
}
553
560
@@ -557,7 +564,7 @@ string GetDownloadUrlForUnityVersion(string releaseUrl)
557
564
/// <param name="url">full url to installer</param>
558
565
void DownloadInBrowser ( string url , string version )
559
566
{
560
- string exeURL = GetDownloadUrlForUnityVersion ( url ) ;
567
+ string exeURL = GetDownloadUrlForUnityVersion ( version ) ;
561
568
if ( string . IsNullOrEmpty ( exeURL ) == false )
562
569
{
563
570
SetStatus ( "Download installer in browser: " + exeURL ) ;
0 commit comments