forked from LavaGang/UDGB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnityVersion.cs
More file actions
73 lines (59 loc) · 2.59 KB
/
UnityVersion.cs
File metadata and controls
73 lines (59 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Collections.Generic;
using _UnityVersion = AssetRipper.Primitives.UnityVersion;
namespace UDGB
{
internal class UnityVersion
{
internal static List<UnityVersion> VersionTbl = new List<UnityVersion>();
internal static string UnityURL = "https://unity3d.com/get-unity/download/archive";
internal _UnityVersion Version = _UnityVersion.MinVersion;
internal string DownloadURL = null;
internal string HashStr = null;
internal bool UsePayloadExtraction = false;
internal UnityVersion(string fullversion, string downloadurl)
{
Version = _UnityVersion.Parse(fullversion);
string[] downloadurl_splices = downloadurl.Split('/');
if (Version < _UnityVersion.Parse("5.3.99") || downloadurl_splices[4].EndsWith(".exe"))
{
Logger.DebugMsg($"{Version.ToStringWithoutType()} - {DownloadURL}");
return;
}
UsePayloadExtraction = true;
HashStr = downloadurl_splices[4];
DownloadURL = $"https://download.unity3d.com/download_unity/{HashStr}/MacEditorTargetInstaller/UnitySetup-Windows-";
if (Version >= _UnityVersion.Parse("2018.0.0"))
DownloadURL += "Mono-";
DownloadURL += $"Support-for-Editor-{Version}.pkg";
Logger.DebugMsg($"{Version.ToStringWithoutType()} - {HashStr} - {DownloadURL}");
}
internal static void Refresh()
{
if (VersionTbl.Count > 0)
VersionTbl.Clear();
string pageSource = Program.webClient.DownloadString(UnityURL);
if (string.IsNullOrEmpty(pageSource))
return;
string target = "unityHubDeepLink\\\":\\\"unityhub://";
int next;
while ((next = pageSource.IndexOf(target)) != -1)
{
pageSource = pageSource.Substring(next + target.Length);
int end = pageSource.IndexOf("\\\"");
if (end == -1)
continue;
string url = pageSource.Substring(0, end);
string[] parts = url.Split('/');
string fullVersion = parts[0];
string hash = parts[1];
string foundUrl = $"https://download.unity3d.com/download_unity/{hash}/Windows64EditorInstaller/UnitySetup64-{fullVersion}.exe";
try
{
VersionTbl.Add(new UnityVersion(fullVersion, foundUrl));
}
catch { }
}
VersionTbl.Reverse();
}
}
}