Skip to content

Commit 65025c8

Browse files
committed
fix array out of index, if removed last recent project item from list, display error message if try to launch from explorer (without any unity editors) #212
1 parent f5f31c0 commit 65025c8

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

UnityLauncherPro/Tools.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ public static Process LaunchProject(Project proj, DataGrid dataGridRef = null, b
274274
var unityExePath = GetUnityExePath(proj.Version);
275275
if (unityExePath == null)
276276
{
277+
// if no editors installed, show message
278+
if (MainWindow.unityInstallationsSource.Count == 0)
279+
{
280+
MessageBox.Show($"No Unity versions installed. Please run {MainWindow.appName} first to setup root folders.", MainWindow.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
281+
return null;
282+
}
283+
277284
DisplayUpgradeDialog(proj, null, useInitScript);
278285
return null;
279286
}
@@ -1665,6 +1672,9 @@ public static void SetFocusToGrid(DataGrid targetGrid, int index = -1)
16651672
DataGridRow row = (DataGridRow)targetGrid.ItemContainerGenerator.ContainerFromIndex(index);
16661673
if (row == null)
16671674
{
1675+
// clamp to max items
1676+
if (index >= targetGrid.Items.Count) index = targetGrid.Items.Count - 1;
1677+
16681678
targetGrid.ScrollIntoView(targetGrid.Items[index]);
16691679
// Defer the focus once row is generated
16701680
targetGrid.Dispatcher.InvokeAsync(() =>

UnityLauncherPro/UpgradeWindow.xaml.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
2626

2727
gridAvailableVersions.SelectedItem = null;
2828

29-
// we have current version info in project
30-
// enable release and dl buttons
31-
btnOpenReleasePage.IsEnabled = true;
32-
btnDownload.IsEnabled = true;
33-
3429
// if dont have exact version, show red outline
3530
if (currentVersion == null || MainWindow.unityInstalledVersions.ContainsKey(currentVersion) == false)
3631
{
@@ -40,6 +35,10 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
4035

4136
if (currentVersion != null)
4237
{
38+
// we know the version, enable buttons
39+
btnOpenReleasePage.IsEnabled = true;
40+
btnDownload.IsEnabled = true;
41+
4342
// remove china c1 from version
4443
if (currentVersion.Contains("c")) currentVersion = currentVersion.Replace("c1", "");
4544
// find nearest version
@@ -150,6 +149,13 @@ private void GridAvailableVersions_PreviewMouseDoubleClick(object sender, MouseB
150149
void Upgrade()
151150
{
152151
var k = (UnityInstallation)gridAvailableVersions.SelectedItem;
152+
153+
if (k == null)
154+
{
155+
DialogResult = false;
156+
return;
157+
}
158+
153159
upgradeVersion = k.Version;
154160
DialogResult = true;
155161
}

0 commit comments

Comments
 (0)