10
10
using System . Drawing ; // for notifyicon
11
11
using System . IO ;
12
12
using System . Runtime . InteropServices ;
13
+ using System . Text . RegularExpressions ;
13
14
using System . Threading ;
14
15
using System . Threading . Tasks ;
15
16
using System . Windows ;
@@ -62,6 +63,7 @@ public partial class MainWindow : Window
62
63
Dictionary < string , SolidColorBrush > origResourceColors = new Dictionary < string , SolidColorBrush > ( ) ;
63
64
64
65
string currentBuildReportProjectPath = null ;
66
+ string currentBuildPluginsRelativePath = null ;
65
67
//List<List<string>> buildReports = new List<List<string>>();
66
68
List < BuildReport > buildReports = new List < BuildReport > ( ) ; // multiple reports, each contains their own stats and items
67
69
int currentBuildReport = 0 ;
@@ -2124,6 +2126,7 @@ void RefreshBuildReports()
2124
2126
2125
2127
try
2126
2128
{
2129
+ // read editor.log file
2127
2130
using ( FileStream fs = new FileStream ( logFile , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) )
2128
2131
{
2129
2132
using ( StreamReader sr = new StreamReader ( fs ) )
@@ -2134,6 +2137,7 @@ void RefreshBuildReports()
2134
2137
2135
2138
bool gotProjectPath = false ;
2136
2139
bool hasTimeStamps = false ;
2140
+ bool gotOutputPluginsPath = false ;
2137
2141
2138
2142
// TODO cleanup here
2139
2143
while ( ! sr . EndOfStream )
@@ -2147,10 +2151,31 @@ void RefreshBuildReports()
2147
2151
gotProjectPath = false ;
2148
2152
}
2149
2153
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
+
2150
2171
// if have timestamps, trim until 2nd | char at start
2151
2172
2152
2173
// check arguments
2153
2174
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
+
2154
2179
if ( hasTimeStamps == false && line . IndexOf ( "-timestamps" ) > - 1 )
2155
2180
{
2156
2181
hasTimeStamps = true ;
@@ -2220,6 +2245,30 @@ void RefreshBuildReports()
2220
2245
string streamingAssetPath = Path . Combine ( currentBuildReportProjectPath , "Assets" , "StreamingAssets" ) ;
2221
2246
var streamingAssetFolderSize = Tools . GetFolderSizeInBytes ( streamingAssetPath ) ;
2222
2247
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
+
2223
2272
}
2224
2273
else
2225
2274
{
0 commit comments