Skip to content

Commit 9a29eab

Browse files
committed
add initial support for unity source build output folder, add build report search filter, fix file in use error for build report reader, add open release notes context menu for Updates
1 parent 75acb42 commit 9a29eab

File tree

3 files changed

+121
-9
lines changed

3 files changed

+121
-9
lines changed

UnityLauncherPro/GetUnityInstallations.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace UnityLauncherPro
99
/// </summary>
1010
public static class GetUnityInstallations
1111
{
12-
//static Dictionary<string, string> platformNames = new Dictionary<string, string> { { "androidplayer", "Android" }, { "windowsstandalonesupport", "Windows" }, { "linuxstandalonesupport", "Linux" }, { "LinuxStandalone", "Linux" }, { "OSXStandalone", "Mac" }, { "webglsupport", "WebGL" }, { "metrosupport", "UWP" } };
1312
static Dictionary<string, string> platformNames = new Dictionary<string, string> { { "androidplayer", "Android" }, { "windowsstandalonesupport", "Standalone" }, { "linuxstandalonesupport", "Standalone" }, { "LinuxStandalone", "Standalone" }, { "OSXStandalone", "Standalone" }, { "webglsupport", "WebGL" }, { "metrosupport", "UWP" } };
1413

1514

@@ -33,18 +32,30 @@ public static UnityInstallation[] Scan()
3332
// parse all folders under root, and search for unity editor files
3433
for (int i = 0, length = directories.Length; i < length; i++)
3534
{
36-
// check if uninstaller is there, sure sign for unity
37-
var uninstallExe = Path.Combine(directories[i], "Editor", "Uninstall.exe");
35+
var editorFolder = Path.Combine(directories[i], "Editor");
36+
if (Directory.Exists(editorFolder) == false)
37+
{
38+
// OPTIONAL scan for source code build output
39+
editorFolder = Path.Combine(directories[i], "build/WindowsEditor/x64/Release");
40+
if (Directory.Exists(editorFolder) == false)
41+
{
42+
// no unity editor root folder found, skip this folder
43+
continue;
44+
}
45+
}
46+
47+
// check if uninstaller is there, sure sign of unity
48+
var uninstallExe = Path.Combine(editorFolder, "Uninstall.exe");
3849
var haveUninstaller = File.Exists(uninstallExe);
3950

40-
var exePath = Path.Combine(directories[i], "Editor", "Unity.exe");
51+
var exePath = Path.Combine(editorFolder, "Unity.exe");
4152
if (File.Exists(exePath) == false) continue;
4253

4354
// get full version number from uninstaller (or try exe, if no uninstaller)
4455
var version = Tools.GetFileVersionData(haveUninstaller ? uninstallExe : exePath);
4556

4657
// we got new version to add
47-
var dataFolder = Path.Combine(directories[i], "Editor", "Data");
58+
var dataFolder = Path.Combine(editorFolder, "Data");
4859
DateTime? installDate = Tools.GetLastModifiedTime(dataFolder);
4960
UnityInstallation unity = new UnityInstallation();
5061
unity.Version = version;

UnityLauncherPro/MainWindow.xaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@
634634
<MenuItem x:Name="menuItemCopyEditorPath" Header="Copy Editor Path" Click="MenuItemCopyPath_Click" />
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"/>
637+
<!--<MenuItem x:Name="menuItemEditPackages" Header="Edit Packages" Click="MenuItemEditPackages_Click"/>-->
637638
</ContextMenu>
638639
</DataGrid.ContextMenu>
639640

@@ -726,6 +727,7 @@
726727
<ContextMenu>
727728
<MenuItem x:Name="menuItemCopyUpdatesVersion" Header="Copy Unity Version" Click="MenuItemCopyVersion_Click" />
728729
<MenuItem x:Name="menuItemCopyUpdateDownloadURL" Header="Copy Download URL" Click="MenuItemCopyUpdateDownloadURL_Click" />
730+
<MenuItem x:Name="menuItemUpdatesReleaseNotes" Header="Open Release Notes" Click="MenuItemUpdatesReleaseNotes_Click" />
729731
</ContextMenu>
730732
</DataGrid.ContextMenu>
731733
<local:Updates ReleaseDate="2020-10-10" Version="5000.1.2.3"/>
@@ -800,6 +802,30 @@
800802
<Button x:Name="btnClearBuildReport" Style="{StaticResource CustomButton}" ToolTip="Clear report" Content="🗑" Height="22" Width="22" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="16" Margin="0,4,10,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnClearBuildReport_Click" />
801803
<Button x:Name="btnRefreshBuildReport" Style="{StaticResource CustomButton}" ToolTip="Get latest Build Report from Editor.log" Content="" Height="22" Width="22" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="16" Margin="0,4,10,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshBuildReport_Click"/>
802804
<!--<CheckBox x:Name="chkAutoUpdateBuildReport" Content="AutoUpdate" Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" ToolTip="" HorizontalAlignment="Right" VerticalAlignment="Top" Height="26" VerticalContentAlignment="Center" IsEnabled="False"/>-->
805+
806+
<!-- search box -->
807+
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
808+
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBoxBuildReport}" Height="24" />
809+
<TextBox MinWidth="100" CaretBrush="{DynamicResource ThemeSearchCaret}" x:Name="txtSearchBoxBuildReport" Background="Transparent" BorderBrush="{x:Null}" Foreground="{DynamicResource ThemeSearchForeground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxBuildReport_PreviewKeyDown" TextChanged="TxtSearchBoxBuildReport_TextChanged" />
810+
<Button x:Name="btnClearBuildReportSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="BtnClearBuildReportSearch_Click">
811+
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ThemeSearchCaret}" Padding="5,3,4,4" HorizontalAlignment="Center">
812+
<TextBlock.Style>
813+
<Style TargetType="{x:Type TextBlock}">
814+
<Style.Triggers>
815+
<DataTrigger Binding="{Binding Text, ElementName=txtSearchBoxBuildReport}" Value="">
816+
<Setter Property="Visibility" Value="Hidden"/>
817+
</DataTrigger>
818+
<DataTrigger Binding="{Binding Text, ElementName=txtSearchBoxBuildReport}" Value="{x:Null}">
819+
<Setter Property="Visibility" Value="Hidden"/>
820+
</DataTrigger>
821+
</Style.Triggers>
822+
</Style>
823+
</TextBlock.Style>
824+
</TextBlock>
825+
</Button>
826+
</Grid>
827+
828+
803829
</StackPanel>
804830
<DataGrid x:Name="gridBuildReport" SelectionMode="Single" Margin="4,30,2,0" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeGridHorizontalGridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" VerticalAlignment="Top" PreviewMouseDoubleClick="GridBuildReport_PreviewMouseDoubleClick">
805831
<DataGrid.Columns>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ void FilterUnitys()
244244
}
245245
}
246246

247+
void FilterBuildReport()
248+
{
249+
_filterString = txtSearchBoxBuildReport.Text;
250+
ICollectionView collection = CollectionViewSource.GetDefaultView(gridBuildReport.ItemsSource);
251+
collection.Filter = BuildReportFilter;
252+
//if (gridBuildReport.Items.Count > 0)
253+
//{
254+
// gridBuildReport.SelectedIndex = 0;
255+
//}
256+
}
257+
247258
private bool ProjectFilter(object item)
248259
{
249260
Project proj = item as Project;
@@ -262,6 +273,12 @@ private bool UnitysFilter(object item)
262273
return (unity.Version.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1);
263274
}
264275

276+
private bool BuildReportFilter(object item)
277+
{
278+
BuildReportItem reportItem = item as BuildReportItem;
279+
return (reportItem.Path.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1);
280+
}
281+
265282
void LoadSettings()
266283
{
267284
// form size
@@ -736,6 +753,18 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
736753
break;
737754
}
738755
break;
756+
757+
case 3: // Tools
758+
759+
switch (e.Key)
760+
{
761+
case Key.Escape: // clear search
762+
txtSearchBoxBuildReport.Text = "";
763+
break;
764+
default: // any key
765+
break;
766+
}
767+
break;
739768
default:
740769
break;
741770
}
@@ -1706,7 +1735,14 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
17061735
if (File.Exists(logFile) == false) return;
17071736

17081737
// NOTE this can fail on a HUGE log file
1709-
string[] rows = File.ReadAllLines(logFile);
1738+
FileStream fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
1739+
StreamReader sr = new StreamReader(fs);
1740+
List<string> rows = new List<string>();
1741+
while (!sr.EndOfStream)
1742+
{
1743+
rows.Add(sr.ReadLine());
1744+
}
1745+
17101746

17111747
if (rows == null)
17121748
{
@@ -1717,7 +1753,7 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
17171753
int startRow = -1;
17181754
int endRow = -1;
17191755

1720-
for (int i = 0, len = rows.Length; i < len; i++)
1756+
for (int i = 0, len = rows.Count; i < len; i++)
17211757
{
17221758
// get current project path from log file
17231759
if (rows[i] == "-projectPath")
@@ -1729,14 +1765,14 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
17291765
if (string.IsNullOrEmpty(latestBuildReportProjectPath)) Console.WriteLine("Failed to parse project path from logfile..");
17301766

17311767
// loop backwards to find latest report
1732-
for (int i = rows.Length - 1; i >= 0; i--)
1768+
for (int i = rows.Count - 1; i >= 0; i--)
17331769
{
17341770
// find start of build report
17351771
if (rows[i].IndexOf("Used Assets and files from the Resources folder, sorted by uncompressed size:") == 0)
17361772
{
17371773
startRow = i + 1;
17381774
// find end of report
1739-
for (int k = i; k < rows.Length; k++)
1775+
for (int k = i, len = rows.Count; k < len; k++)
17401776
{
17411777
if (rows[k].IndexOf("-------------------------------------------------------------------------------") == 0)
17421778
{
@@ -2112,5 +2148,44 @@ private void ChkRunAutomaticallyMinimized_Checked(object sender, RoutedEventArgs
21122148
Properties.Settings.Default.runAutomaticallyMinimized = isChecked;
21132149
Properties.Settings.Default.Save();
21142150
}
2151+
2152+
private void MenuItemEditPackages_Click(object sender, RoutedEventArgs e)
2153+
{
2154+
// TODO read Editor\Data\Resources\PackageManager\Editor\manifest.json
2155+
// TODO read list of buildin packages *or no need, its com.unity.modules.*
2156+
// TODO show list of packages (with buildin packages hidden from the list)
2157+
// TODO user can enable/disable packages
2158+
// TODO save back to the JSON file (NOTE cannot write if not admin! need to run some batch command elevated to overwrite file?)
2159+
// TODO or, allow setting filter for packages (so can have custom "dont want"-packages list, and then remove those automatically! (from generated project, so original manifest can stay, but at which point..)
2160+
}
2161+
2162+
private void MenuItemUpdatesReleaseNotes_Click(object sender, RoutedEventArgs e)
2163+
{
2164+
var unity = GetSelectedUpdate();
2165+
Tools.OpenReleaseNotes(unity?.Version);
2166+
}
2167+
2168+
private void BtnClearBuildReportSearch_Click(object sender, RoutedEventArgs e)
2169+
{
2170+
txtSearchBoxBuildReport.Text = "";
2171+
}
2172+
2173+
private void TxtSearchBoxBuildReport_PreviewKeyDown(object sender, KeyEventArgs e)
2174+
{
2175+
switch (e.Key)
2176+
{
2177+
case Key.Up:
2178+
case Key.Down:
2179+
Tools.SetFocusToGrid(gridBuildReport);
2180+
break;
2181+
default:
2182+
break;
2183+
}
2184+
}
2185+
2186+
private void TxtSearchBoxBuildReport_TextChanged(object sender, TextChangedEventArgs e)
2187+
{
2188+
if (gridBuildReport.ItemsSource != null) FilterBuildReport();
2189+
}
21152190
} // class
21162191
} //namespace

0 commit comments

Comments
 (0)