1010using System . Drawing ; // for notifyicon
1111using System . IO ;
1212using System . Runtime . InteropServices ;
13+ using System . Text . RegularExpressions ;
1314using System . Threading ;
1415using System . Threading . Tasks ;
1516using System . Windows ;
@@ -62,6 +63,7 @@ public partial class MainWindow : Window
6263 Dictionary < string , SolidColorBrush > origResourceColors = new Dictionary < string , SolidColorBrush > ( ) ;
6364
6465 string currentBuildReportProjectPath = null ;
66+ string currentBuildPluginsRelativePath = null ;
6567 //List<List<string>> buildReports = new List<List<string>>();
6668 List < BuildReport > buildReports = new List < BuildReport > ( ) ; // multiple reports, each contains their own stats and items
6769 int currentBuildReport = 0 ;
@@ -2124,6 +2126,7 @@ void RefreshBuildReports()
21242126
21252127 try
21262128 {
2129+ // read editor.log file
21272130 using ( FileStream fs = new FileStream ( logFile , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) )
21282131 {
21292132 using ( StreamReader sr = new StreamReader ( fs ) )
@@ -2134,6 +2137,7 @@ void RefreshBuildReports()
21342137
21352138 bool gotProjectPath = false ;
21362139 bool hasTimeStamps = false ;
2140+ bool gotOutputPluginsPath = false ;
21372141
21382142 // TODO cleanup here
21392143 while ( ! sr . EndOfStream )
@@ -2147,10 +2151,31 @@ void RefreshBuildReports()
21472151 gotProjectPath = false ;
21482152 }
21492153
2154+ if ( gotOutputPluginsPath == true )
2155+ {
2156+ // get output plugins folder relative path, this might not always work, if there is not copyfiles line in log
2157+ string pattern = @"CopyFiles\s+(.+?)/\w+\.\w+$" ;
2158+ Match match = Regex . Match ( line , pattern ) ;
2159+ if ( match . Success )
2160+ {
2161+ string folder = match . Groups [ 1 ] . Value ; //.Replace("CopyFiles ", "");
2162+ if ( folder . IndexOf ( "_Data/Plugins" ) > - 1 )
2163+ {
2164+ currentBuildPluginsRelativePath = folder ;
2165+ }
2166+ }
2167+
2168+ gotOutputPluginsPath = false ;
2169+ }
2170+
21502171 // if have timestamps, trim until 2nd | char at start
21512172
21522173 // check arguments
21532174 if ( line . IndexOf ( "-projectPath" ) > - 1 ) gotProjectPath = true ;
2175+
2176+ // NOTE only works if your build path is inside Assets/Builds/ folder
2177+ if ( line . IndexOf ( "CopyFiles" ) > - 1 && line . ToLower ( ) . IndexOf ( "builds/" ) > - 1 ) gotOutputPluginsPath = true ;
2178+
21542179 if ( hasTimeStamps == false && line . IndexOf ( "-timestamps" ) > - 1 )
21552180 {
21562181 hasTimeStamps = true ;
@@ -2220,6 +2245,30 @@ void RefreshBuildReports()
22202245 string streamingAssetPath = Path . Combine ( currentBuildReportProjectPath , "Assets" , "StreamingAssets" ) ;
22212246 var streamingAssetFolderSize = Tools . GetFolderSizeInBytes ( streamingAssetPath ) ;
22222247 singleReport . Stats . Insert ( singleReport . Stats . Count - 1 , new BuildReportItem ( ) { Category = "StreamingAssets" , Size = Tools . GetBytesReadable ( streamingAssetFolderSize ) } ) ;
2248+
2249+
2250+ // get total Plugins/ folder size from build! (but how to get last build output folder, its not mentioned in editor log (except some lines for CopyFiles/ but are those always there?)
2251+ // Library\PlayerDataCache\Linux641\ScriptsOnlyCache.yaml also contains output path
2252+ if ( string . IsNullOrEmpty ( currentBuildPluginsRelativePath ) == false )
2253+ {
2254+ //Console.WriteLine("Getting output plugins folder size: "+ currentBuildPluginsRelativePath);
2255+ string pluginFolder = Path . Combine ( currentBuildReportProjectPath , currentBuildPluginsRelativePath ) ;
2256+ long totalPluginFolderSize = Tools . GetFolderSizeInBytes ( pluginFolder ) ;
2257+ singleReport . Stats . Insert ( singleReport . Stats . Count - 1 , new BuildReportItem ( ) { Category = "Plugins" , Size = Tools . GetBytesReadable ( totalPluginFolderSize ) } ) ;
2258+ }
2259+ else // then show plugin folders from project (with * to mark this is not accurate)
2260+ {
2261+ // get plugin folder sizes (they are not included in build report!), NOTE need to iterate all subfolders, as they might contain Plugins/ folders
2262+ // find all plugin folders inside Assets/
2263+ var pluginFolders = Directory . GetDirectories ( Path . Combine ( currentBuildReportProjectPath , "Assets" ) , "Plugins" , SearchOption . AllDirectories ) ;
2264+ long totalPluginFolderSize = 0 ;
2265+ foreach ( var pluginFolder in pluginFolders )
2266+ {
2267+ totalPluginFolderSize += Tools . GetFolderSizeInBytes ( pluginFolder ) ;
2268+ }
2269+ singleReport . Stats . Insert ( singleReport . Stats . Count - 1 , new BuildReportItem ( ) { Category = "Plugins *in proj!" , Size = Tools . GetBytesReadable ( totalPluginFolderSize ) } ) ;
2270+ }
2271+
22232272 }
22242273 else
22252274 {
0 commit comments