Skip to content

Commit beadc28

Browse files
committed
handle null version for new project folder open fixes #189
1 parent f91906c commit beadc28

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

UnityLauncherPro/MainWindow.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void Start()
122122
UpdateUnityInstallationsList();
123123
HandleCommandLineLaunch();
124124

125+
125126
// check for duplicate instance, and activate that instead
126127
if (chkAllowSingleInstanceOnly.IsChecked == true)
127128
{

UnityLauncherPro/UpgradeWindow.xaml.cs

+17-16
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,29 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
3232
btnDownload.IsEnabled = true;
3333

3434
// if dont have exact version, show red outline
35-
if (MainWindow.unityInstalledVersions.ContainsKey(currentVersion) == false)
35+
if (currentVersion == null || MainWindow.unityInstalledVersions.ContainsKey(currentVersion) == false)
3636
{
3737
txtCurrentVersion.BorderBrush = Brushes.Red;
3838
txtCurrentVersion.BorderThickness = new Thickness(1);
3939
}
40-
41-
// remove china c1 from version
42-
if (currentVersion.Contains('c')) currentVersion= currentVersion.Replace("c1", "");
43-
44-
// find nearest version
45-
string nearestVersion = Tools.FindNearestVersion(currentVersion, MainWindow.unityInstalledVersions.Keys.ToList());
46-
47-
if (nearestVersion != null)
40+
else // not null
4841
{
49-
// select nearest version
50-
for (int i = 0; i < MainWindow.unityInstallationsSource.Count; i++)
42+
// remove china c1 from version
43+
if (currentVersion.Contains('c')) currentVersion = currentVersion.Replace("c1", "");
44+
// find nearest version
45+
string nearestVersion = Tools.FindNearestVersion(currentVersion, MainWindow.unityInstalledVersions.Keys.ToList());
46+
47+
if (nearestVersion != null)
5148
{
52-
if (MainWindow.unityInstallationsSource[i].Version == nearestVersion)
49+
// select nearest version
50+
for (int i = 0; i < MainWindow.unityInstallationsSource.Count; i++)
5351
{
54-
gridAvailableVersions.SelectedIndex = i;
55-
gridAvailableVersions.ScrollIntoView(gridAvailableVersions.SelectedItem);
56-
break;
52+
if (MainWindow.unityInstallationsSource[i].Version == nearestVersion)
53+
{
54+
gridAvailableVersions.SelectedIndex = i;
55+
gridAvailableVersions.ScrollIntoView(gridAvailableVersions.SelectedItem);
56+
break;
57+
}
5758
}
5859
}
5960
}
@@ -77,7 +78,7 @@ private void BtnOpenReleasePage_Click(object sender, RoutedEventArgs e)
7778
Tools.OpenReleaseNotes(txtCurrentVersion.Text);
7879
}
7980

80-
81+
8182
private void BtnDownloadEditor_Click(object sender, RoutedEventArgs e)
8283
{
8384
Tools.DownloadInBrowser(txtCurrentVersion.Text);

0 commit comments

Comments
 (0)