Skip to content

Commit

Permalink
Upgrade project: Fix null ref for selected row, Updates: Download & R…
Browse files Browse the repository at this point in the history
…un, Set installation path using commandline argument to installer (using editor root path + unity base version)
  • Loading branch information
unitycoder committed Mar 20, 2023
1 parent e11c09a commit df1d56a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
30 changes: 7 additions & 23 deletions UnityLauncherPro/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,35 +580,19 @@ public static void DownloadAndInstall(string url, string version)
// TODO make async
if (DownloadFile(exeURL, tempFile) == true)
{
// run installer, copy current existing version path to clipboard, NOTE this probably never happens? unless install same version again..
if (MainWindow.unityInstalledVersions.ContainsKey(version) == true)
{
string path = MainWindow.unityInstalledVersions[version];
if (string.IsNullOrEmpty(path) == false)
{
// copy to clipboard
Clipboard.SetText(path);
}
}
else // no same version, copy last item from root folders
{
if (Properties.Settings.Default.rootFolders.Count > 0)
{
string path = Properties.Settings.Default.rootFolders[Properties.Settings.Default.rootFolders.Count - 1];
if (string.IsNullOrEmpty(path) == false)
{
Clipboard.SetText(path);
}
}
}
// get base version, to use for install path
string outputVersionFolder = "\\" + version.Split('.')[0] + "_" + version.Split('.')[1];
string targetPathArgs = " /D=" + Properties.Settings.Default.rootFolders[Properties.Settings.Default.rootFolders.Count - 1] + outputVersionFolder; ;

Process process;
// if user clicks NO to UAC, this fails (so added try-catch)
try
{
process = Process.Start(tempFile);
Process process = new Process();
process.StartInfo.FileName = tempFile;
process.StartInfo.Arguments = targetPathArgs;
process.EnableRaisingEvents = true;
process.Exited += (sender, e) => DeleteTempFile(tempFile);
process.Start();
}
catch (Exception)
{
Expand Down
4 changes: 2 additions & 2 deletions UnityLauncherPro/UpgradeWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventA
if (e.Key == Key.Return && e.KeyboardDevice.Modifiers == ModifierKeys.None)
{
e.Handled = true;
var k = (gridAvailableVersions.SelectedItem) as KeyValuePair<string, string>?;
upgradeVersion = k.Value.Key;
var k = (UnityInstallation)gridAvailableVersions.SelectedItem;
upgradeVersion = k.Version;
DialogResult = true;
return;
}
Expand Down

0 comments on commit df1d56a

Please sign in to comment.