Skip to content

Commit df1d56a

Browse files
committed
Upgrade project: Fix null ref for selected row, Updates: Download & Run, Set installation path using commandline argument to installer (using editor root path + unity base version)
1 parent e11c09a commit df1d56a

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

UnityLauncherPro/Tools.cs

+7-23
Original file line numberDiff line numberDiff line change
@@ -580,35 +580,19 @@ public static void DownloadAndInstall(string url, string version)
580580
// TODO make async
581581
if (DownloadFile(exeURL, tempFile) == true)
582582
{
583-
// run installer, copy current existing version path to clipboard, NOTE this probably never happens? unless install same version again..
584-
if (MainWindow.unityInstalledVersions.ContainsKey(version) == true)
585-
{
586-
string path = MainWindow.unityInstalledVersions[version];
587-
if (string.IsNullOrEmpty(path) == false)
588-
{
589-
// copy to clipboard
590-
Clipboard.SetText(path);
591-
}
592-
}
593-
else // no same version, copy last item from root folders
594-
{
595-
if (Properties.Settings.Default.rootFolders.Count > 0)
596-
{
597-
string path = Properties.Settings.Default.rootFolders[Properties.Settings.Default.rootFolders.Count - 1];
598-
if (string.IsNullOrEmpty(path) == false)
599-
{
600-
Clipboard.SetText(path);
601-
}
602-
}
603-
}
583+
// get base version, to use for install path
584+
string outputVersionFolder = "\\" + version.Split('.')[0] + "_" + version.Split('.')[1];
585+
string targetPathArgs = " /D=" + Properties.Settings.Default.rootFolders[Properties.Settings.Default.rootFolders.Count - 1] + outputVersionFolder; ;
604586

605-
Process process;
606587
// if user clicks NO to UAC, this fails (so added try-catch)
607588
try
608589
{
609-
process = Process.Start(tempFile);
590+
Process process = new Process();
591+
process.StartInfo.FileName = tempFile;
592+
process.StartInfo.Arguments = targetPathArgs;
610593
process.EnableRaisingEvents = true;
611594
process.Exited += (sender, e) => DeleteTempFile(tempFile);
595+
process.Start();
612596
}
613597
catch (Exception)
614598
{

UnityLauncherPro/UpgradeWindow.xaml.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventA
138138
if (e.Key == Key.Return && e.KeyboardDevice.Modifiers == ModifierKeys.None)
139139
{
140140
e.Handled = true;
141-
var k = (gridAvailableVersions.SelectedItem) as KeyValuePair<string, string>?;
142-
upgradeVersion = k.Value.Key;
141+
var k = (UnityInstallation)gridAvailableVersions.SelectedItem;
142+
upgradeVersion = k.Version;
143143
DialogResult = true;
144144
return;
145145
}

0 commit comments

Comments
 (0)