@@ -54,6 +54,8 @@ public partial class MainWindow : Window
54
54
Dictionary < string , SolidColorBrush > origResourceColors = new Dictionary < string , SolidColorBrush > ( ) ;
55
55
56
56
string latestBuildReportProjectPath = null ;
57
+ List < List < string > > buildReports = new List < List < string > > ( ) ;
58
+ int currentBuildReport = 0 ;
57
59
58
60
[ DllImport ( "user32" , CharSet = CharSet . Unicode ) ]
59
61
static extern IntPtr FindWindow ( string cls , string win ) ;
@@ -624,7 +626,7 @@ private void OnRectangleMouseDown(object sender, MouseButtonEventArgs e)
624
626
private void OnSearchTextChanged ( object sender , TextChangedEventArgs e )
625
627
{
626
628
FilterRecentProjects ( ) ;
627
-
629
+
628
630
// if nothing selected, select first item
629
631
if ( gridRecent . SelectedIndex < 0 ) gridRecent . SelectedIndex = 0 ;
630
632
}
@@ -1801,22 +1803,49 @@ private void GridRecent_ContextMenuOpening(object sender, ContextMenuEventArgs e
1801
1803
1802
1804
private void BtnRefreshBuildReport_Click ( object sender , RoutedEventArgs e )
1803
1805
{
1804
- var logFile = Path . Combine ( Tools . GetEditorLogsFolder ( ) , "Editor.log" ) ;
1806
+ currentBuildReport = 0 ;
1807
+ buildReports . Clear ( ) ;
1808
+ UpdateBuildReportLabelAndButtons ( ) ;
1809
+
1810
+ btnPrevBuildReport . IsEnabled = false ;
1811
+ btnNextBuildReport . IsEnabled = false ;
1805
1812
1813
+ var logFile = Path . Combine ( Tools . GetEditorLogsFolder ( ) , "Editor.log" ) ;
1806
1814
if ( File . Exists ( logFile ) == false ) return ;
1807
1815
1808
- // NOTE this can fail on a HUGE log file
1809
- List < string > rows = new List < string > ( ) ;
1816
+ List < string > subList = null ;
1817
+
1810
1818
try
1811
1819
{
1812
1820
using ( FileStream fs = new FileStream ( logFile , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) )
1813
1821
{
1814
1822
using ( StreamReader sr = new StreamReader ( fs ) )
1815
1823
{
1824
+ bool collect = false ;
1816
1825
// now we collect all lines, but could collect only those needed below
1817
1826
while ( ! sr . EndOfStream )
1818
1827
{
1819
- rows . Add ( sr . ReadLine ( ) ) ;
1828
+ var line = sr . ReadLine ( ) ;
1829
+ // build report starts, TODO collect report header also
1830
+ if ( collect == false && line . IndexOf ( "Used Assets and files from the Resources folder, sorted by uncompressed size:" ) == 0 )
1831
+ {
1832
+ // init new list for this build report
1833
+ subList = new List < string > ( ) ;
1834
+ collect = true ;
1835
+ continue ;
1836
+ }
1837
+
1838
+ // build report ends
1839
+ if ( collect == true && line . IndexOf ( "-------------------------------------------------------------------------------" ) == 0 )
1840
+ {
1841
+ buildReports . Add ( subList ) ;
1842
+ collect = false ;
1843
+ }
1844
+
1845
+ if ( collect == true )
1846
+ {
1847
+ subList . Add ( line ) ;
1848
+ }
1820
1849
}
1821
1850
}
1822
1851
}
@@ -1827,53 +1856,44 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
1827
1856
return ;
1828
1857
}
1829
1858
1830
- int startRow = - 1 ;
1831
- int endRow = - 1 ;
1832
-
1833
- for ( int i = 0 , len = rows . Count ; i < len ; i ++ )
1859
+ if ( buildReports . Count < 1 || buildReports [ 0 ] . Count < 1 )
1834
1860
{
1835
- // get current project path from log file
1836
- if ( rows [ i ] == "-projectPath" )
1837
- {
1838
- latestBuildReportProjectPath = rows [ i + 1 ] ;
1839
- break ;
1840
- }
1861
+ Console . WriteLine ( "Failed to parse Editor.Log (probably no build reports there)" ) ;
1862
+ return ;
1841
1863
}
1842
- if ( string . IsNullOrEmpty ( latestBuildReportProjectPath ) ) Console . WriteLine ( "Failed to parse project path from logfile.." ) ;
1843
1864
1844
- // loop backwards to find latest report
1845
- for ( int i = rows . Count - 1 ; i >= 0 ; i -- )
1865
+ DisplayBuildReport ( currentBuildReport ) ;
1866
+ }
1867
+
1868
+ private void BtnPrevBuildReport_Click ( object sender , RoutedEventArgs e )
1869
+ {
1870
+ DisplayBuildReport ( -- currentBuildReport ) ;
1871
+ }
1872
+
1873
+ private void BtnNextBuildReport_Click ( object sender , RoutedEventArgs e )
1874
+ {
1875
+ DisplayBuildReport ( ++ currentBuildReport ) ;
1876
+ }
1877
+
1878
+ void DisplayBuildReport ( int index )
1879
+ {
1880
+ if ( currentBuildReport < 0 )
1846
1881
{
1847
- // find start of build report
1848
- if ( rows [ i ] . IndexOf ( "Used Assets and files from the Resources folder, sorted by uncompressed size:" ) == 0 )
1849
- {
1850
- startRow = i + 1 ;
1851
- // find end of report
1852
- for ( int k = i , len = rows . Count ; k < len ; k ++ )
1853
- {
1854
- if ( rows [ k ] . IndexOf ( "-------------------------------------------------------------------------------" ) == 0 )
1855
- {
1856
- endRow = k - 1 ;
1857
- break ;
1858
- }
1859
- }
1860
- break ;
1861
- }
1882
+ currentBuildReport = 0 ;
1862
1883
}
1863
1884
1864
- if ( startRow == - 1 || endRow == - 1 )
1885
+ if ( currentBuildReport > buildReports . Count )
1865
1886
{
1866
- Console . WriteLine ( "Failed to parse Editor.Log (probably no build report there), start= " + startRow + " end= " + endRow ) ;
1867
- return ;
1887
+ currentBuildReport = buildReports . Count - 1 ;
1868
1888
}
1869
1889
1870
- var reportSource = new BuildReportItem [ endRow - startRow ] ;
1890
+ // create build report rows array
1891
+ var reportSource = new List < BuildReportItem > ( ) ;
1871
1892
1872
1893
// parse actual report rows
1873
- int index = 0 ;
1874
- for ( int i = startRow ; i < endRow ; i ++ )
1894
+ for ( int i = 0 , len = buildReports [ currentBuildReport ] . Count ; i < len ; i ++ )
1875
1895
{
1876
- var d = rows [ i ] . Trim ( ) ;
1896
+ var d = buildReports [ currentBuildReport ] [ i ] . Trim ( ) ;
1877
1897
1878
1898
// get tab after kb
1879
1899
var space1 = d . IndexOf ( '\t ' ) ;
@@ -1886,20 +1906,36 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
1886
1906
continue ;
1887
1907
}
1888
1908
1909
+ // create single row
1889
1910
var r = new BuildReportItem ( ) ;
1890
1911
r . Size = d . Substring ( 0 , space1 ) ;
1891
1912
r . Percentage = d . Substring ( space1 + 2 , space2 - space1 - 1 ) ;
1892
1913
r . Path = d . Substring ( space2 + 2 , d . Length - space2 - 2 ) ;
1893
1914
r . Format = Path . GetExtension ( r . Path ) ;
1894
- reportSource [ index ++ ] = r ;
1915
+
1916
+ reportSource . Add ( r ) ;
1895
1917
}
1918
+
1919
+ gridBuildReport . ItemsSource = null ;
1920
+ gridBuildReport . Items . Clear ( ) ;
1896
1921
gridBuildReport . ItemsSource = reportSource ;
1897
1922
1923
+ UpdateBuildReportLabelAndButtons ( ) ;
1924
+ }
1925
+
1926
+ void UpdateBuildReportLabelAndButtons ( )
1927
+ {
1928
+ btnPrevBuildReport . IsEnabled = currentBuildReport > 0 ;
1929
+ btnNextBuildReport . IsEnabled = currentBuildReport < buildReports . Count - 1 ;
1930
+ lblBuildReportIndex . Content = ( buildReports . Count == 0 ? 0 : ( currentBuildReport + 1 ) ) + "/" + ( buildReports . Count ) ;
1898
1931
}
1899
1932
1900
1933
private void BtnClearBuildReport_Click ( object sender , RoutedEventArgs e )
1901
1934
{
1902
1935
gridBuildReport . ItemsSource = null ;
1936
+ currentBuildReport = 0 ;
1937
+ buildReports . Clear ( ) ;
1938
+ UpdateBuildReportLabelAndButtons ( ) ;
1903
1939
}
1904
1940
1905
1941
private void MenuStartWebGLServer_Click ( object sender , RoutedEventArgs e )
@@ -2216,6 +2252,8 @@ void OpenSelectedBuildReportFile()
2216
2252
{
2217
2253
var item = GetSelectedBuildItem ( ) ;
2218
2254
2255
+ Console . WriteLine ( item . Path ) ;
2256
+
2219
2257
if ( item != null )
2220
2258
{
2221
2259
string filePath = Path . Combine ( latestBuildReportProjectPath , item . Path ) ;
@@ -2416,6 +2454,8 @@ private void BtnUnityCache_Click(object sender, RoutedEventArgs e)
2416
2454
Tools . OpenAppdataSpecialFolder ( "Unity/cache" ) ;
2417
2455
}
2418
2456
2457
+
2458
+
2419
2459
//private void BtnBrowseTemplateUnityPackagesFolder_Click(object sender, RoutedEventArgs e)
2420
2460
//{
2421
2461
// var folder = Tools.BrowseForOutputFolder("Select unitypackage Templates folder");
0 commit comments