Skip to content

Commit 020df12

Browse files
committed
fix linux module downloader for recent unity versions
1 parent 7ca4a1e commit 020df12

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

UnityLauncherPro/MainWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@
635635
<MenuItem x:Name="menuItemShowUnityInExplorer" Header="Show in Explorer" Click="MenuItemShowProjectInExplorer_Click" />
636636
<MenuItem x:Name="menuItemSetPreferredUnityVersion" Header="Set as Preferred Version" Click="MenuItemSetPreferredUnityVersion_Click"/>
637637
<!--<MenuItem x:Name="menuItemEditPackages" Header="Edit Packages" Click="MenuItemEditPackages_Click"/>-->
638+
<Separator></Separator>
638639
<MenuItem x:Name="menuItemDownloadLinuxModule" Header="Download Linux modules" Click="MenuItemDownloadLinuxModule_Click"/>
639640
</ContextMenu>
640641
</DataGrid.ContextMenu>

UnityLauncherPro/MainWindow.xaml.cs

+1-25
Original file line numberDiff line numberDiff line change
@@ -2280,31 +2280,7 @@ private void MenuItemDownloadLinuxModule_Click(object sender, RoutedEventArgs e)
22802280
{
22812281
var unity = GetSelectedUnity();
22822282
if (unity == null) return;
2283-
var editorFolder = Path.GetDirectoryName(unity.Path);
2284-
2285-
// TODO move to Tools as DownloadModule(version, exepath..)
2286-
var changeSetFile = Path.Combine(editorFolder, @"Data\PlaybackEngines\windowsstandalonesupport\Source\WindowsPlayer\WindowsPlayer\UnityConfigureRevision.gen.h");
2287-
if (File.Exists(changeSetFile) == true)
2288-
{
2289-
var allText = File.ReadAllText(changeSetFile);
2290-
var hashRaw = allText.Split(new string[] { "#define UNITY_VERSION_HASH \"" }, StringSplitOptions.None);
2291-
if (hashRaw.Length > 1)
2292-
{
2293-
var hash = hashRaw[1].Replace("\"", "");
2294-
2295-
// NOTE downloads now both, mono and il2cpp
2296-
var moduleURL = "https://download.unity3d.com/download_unity/" + hash + "/TargetSupportInstaller/UnitySetup-Linux-IL2CPP-Support-for-Editor-" + unity.Version + ".exe";
2297-
Tools.OpenURL(moduleURL);
2298-
moduleURL = "https://download.unity3d.com/download_unity/" + hash + "/TargetSupportInstaller/UnitySetup-Linux-Mono-Support-for-Editor-" + unity.Version + ".exe";
2299-
Tools.OpenURL(moduleURL);
2300-
}
2301-
}
2302-
else
2303-
{
2304-
Console.WriteLine("Changeset hash file not found: " + changeSetFile);
2305-
}
2306-
2307-
2283+
Tools.DownloadLinuxModules(unity.Path, unity.Version);
23082284
}
23092285
} // class
23102286
} //namespace

UnityLauncherPro/Tools.cs

+44
Original file line numberDiff line numberDiff line change
@@ -1188,5 +1188,49 @@ public static void BringProcessToFront(Process process)
11881188
SetForegroundWindow(handle);
11891189
}
11901190

1191+
public static void DownloadLinuxModules(string UnityExePath, string unityVersion)
1192+
{
1193+
var editorFolder = Path.GetDirectoryName(UnityExePath);
1194+
1195+
string hash = null;
1196+
1197+
// get from unity exe (only for 2018.4 and later?)
1198+
var versionInfo = FileVersionInfo.GetVersionInfo(UnityExePath);
1199+
var versionRaw = versionInfo.ProductVersion.Split('_');
1200+
if (versionRaw.Length == 2)
1201+
{
1202+
hash = versionRaw[1];
1203+
}
1204+
else // try other files
1205+
{
1206+
var changeSetFile = Path.Combine(editorFolder, @"Data\PlaybackEngines\windowsstandalonesupport\Source\WindowsPlayer\WindowsPlayer\UnityConfigureRevision.gen.h");
1207+
if (File.Exists(changeSetFile) == true)
1208+
{
1209+
var allText = File.ReadAllText(changeSetFile);
1210+
var hashRaw = allText.Split(new string[] { "#define UNITY_VERSION_HASH \"" }, StringSplitOptions.None);
1211+
if (hashRaw.Length > 1)
1212+
{
1213+
hash = hashRaw[1].Replace("\"", "");
1214+
}
1215+
else
1216+
{
1217+
Console.WriteLine("Unable to parse UNITY_VERSION_HASH from " + changeSetFile);
1218+
}
1219+
}
1220+
else
1221+
{
1222+
Console.WriteLine("Changeset hash file not found: " + changeSetFile);
1223+
}
1224+
}
1225+
1226+
if (hash == null) return;
1227+
1228+
// NOTE downloads now both, mono and il2cpp
1229+
var moduleURL = "https://download.unity3d.com/download_unity/" + hash + "/TargetSupportInstaller/UnitySetup-Linux-IL2CPP-Support-for-Editor-" + unityVersion + ".exe";
1230+
OpenURL(moduleURL);
1231+
moduleURL = "https://download.unity3d.com/download_unity/" + hash + "/TargetSupportInstaller/UnitySetup-Linux-Mono-Support-for-Editor-" + unityVersion + ".exe";
1232+
OpenURL(moduleURL);
1233+
}
1234+
11911235
} // class
11921236
} // namespace

0 commit comments

Comments
 (0)