@@ -57,6 +57,7 @@ public static class BuildScript
57
57
{ "androidKeystorePass" , "androidKeyaliasName" , "androidKeyaliasPass" } ;
58
58
59
59
private static BuildPlayerOptions buildPlayerOptions ;
60
+ private static List < string > errorLogMessages = new List < string > ( ) ;
60
61
61
62
[ UsedImplicitly ]
62
63
public static void BuildWithCommandlineArgs ( )
@@ -121,26 +122,32 @@ public static void Build(string[] args)
121
122
if ( tagParameters . Contains ( "minsize" ) )
122
123
{
123
124
PlayerSettings . WebGL . template = "PROJECT:Release" ;
124
- SetWebGlOptimization ( CodeOptimizationSize ) ;
125
125
buildPlayerOptions . options |= BuildOptions . CompressWithLz4HC ;
126
126
PlayerSettings . WebGL . exceptionSupport = WebGLExceptionSupport . None ;
127
- PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Master ) ;
127
+ SetWebGlOptimization ( CodeOptimizationSize ) ;
128
128
#if UNITY_2022_1_OR_NEWER
129
129
PlayerSettings . SetIl2CppCodeGeneration ( namedBuildTarget , Il2CppCodeGeneration . OptimizeSize ) ;
130
+ #endif
131
+ #if UNITY_2021_2_OR_NEWER
132
+ PlayerSettings . SetIl2CppCompilerConfiguration ( namedBuildTarget , Il2CppCompilerConfiguration . Master ) ;
133
+ #else
134
+ PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Master ) ;
130
135
#endif
131
136
}
132
137
else if ( tagParameters . Contains ( "debug" ) )
133
138
{
134
139
PlayerSettings . WebGL . template = "PROJECT:Develop" ;
135
140
PlayerSettings . WebGL . exceptionSupport = WebGLExceptionSupport . FullWithStacktrace ;
136
- PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Debug ) ;
141
+ // For debug builds this setting will always be build times no matter what is set, setting this more as a documentation of the behavior
137
142
SetWebGlOptimization ( CodeOptimizationBuildTimes ) ;
138
143
#if UNITY_2022_1_OR_NEWER
139
144
PlayerSettings . SetIl2CppCodeGeneration ( namedBuildTarget , Il2CppCodeGeneration . OptimizeSize ) ;
140
145
#endif
141
146
#if UNITY_2021_2_OR_NEWER
147
+ PlayerSettings . SetIl2CppCompilerConfiguration ( namedBuildTarget , Il2CppCompilerConfiguration . Debug ) ;
142
148
PlayerSettings . WebGL . debugSymbolMode = WebGLDebugSymbolMode . Embedded ;
143
149
#else
150
+ PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Debug ) ;
144
151
PlayerSettings . WebGL . debugSymbols = true ;
145
152
#endif
146
153
@@ -152,18 +159,27 @@ public static void Build(string[] args)
152
159
else
153
160
{
154
161
PlayerSettings . WebGL . template = "PROJECT:Develop" ;
155
- PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Master ) ;
156
162
// By default use the speed setting
157
163
SetWebGlOptimization ( CodeOptimizationSpeed ) ;
158
164
#if UNITY_2022_1_OR_NEWER
159
165
PlayerSettings . SetIl2CppCodeGeneration ( namedBuildTarget , Il2CppCodeGeneration . OptimizeSpeed ) ;
166
+ #endif
167
+ #if UNITY_2021_2_OR_NEWER
168
+ PlayerSettings . SetIl2CppCompilerConfiguration ( namedBuildTarget , Il2CppCompilerConfiguration . Master ) ;
169
+ #else
170
+ PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Master ) ;
160
171
#endif
161
172
}
162
173
163
174
List < GraphicsDeviceType > graphicsAPIs = new List < GraphicsDeviceType > ( ) ;
164
175
if ( tagParameters . Contains ( "webgl1" ) )
165
176
{
177
+ #if ! UNITY_2023_1_OR_NEWER
166
178
graphicsAPIs . Add ( GraphicsDeviceType . OpenGLES2 ) ;
179
+ #else
180
+ LogWarning ( "WebGL1 not supported anymore, choosing WebGL2 instead" ) ;
181
+ graphicsAPIs . Add ( GraphicsDeviceType . OpenGLES3 ) ;
182
+ #endif
167
183
}
168
184
if ( tagParameters . Contains ( "webgl2" ) )
169
185
{
@@ -173,19 +189,14 @@ public static void Build(string[] args)
173
189
{
174
190
#if UNITY_2023_2_OR_NEWER
175
191
graphicsAPIs . Add ( GraphicsDeviceType . WebGPU ) ;
192
+ // Enable wasm2023 for WebGPU, since if webGPU is supported everything from 2023 is supported as well
193
+ PlayerSettings . WebGL . wasm2023 = true ;
176
194
#else
177
195
LogError ( "WebGPU not supported yet" ) ;
178
196
#endif
179
197
}
180
198
181
199
PlayerSettings . SetGraphicsAPIs ( BuildTarget . WebGL , graphicsAPIs . ToArray ( ) ) ;
182
-
183
- #if UNITY_2023_1_OR_NEWER
184
- if ( tagParameters . Contains ( "webgl1" ) )
185
- {
186
- Log ( "WebGL1 not supported anymore, choosing WebGL2 instead" ) ;
187
- }
188
- #endif
189
200
}
190
201
191
202
break ;
@@ -203,11 +214,22 @@ public static void Build(string[] args)
203
214
BackupLastBuild ( $ "{ projectPath } /{ options [ "customBuildPath" ] } ") ;
204
215
}
205
216
217
+ errorLogMessages = new List < string > ( ) ;
218
+ Application . logMessageReceived += OnLogMessageReceived ;
219
+
206
220
// Custom build
207
221
Build ( buildTarget , options [ "customBuildPath" ] ) ;
208
222
}
209
223
210
- private static void BackupLastBuild ( string buildPath )
224
+ private static void OnLogMessageReceived ( string logString , string stackTrace , LogType type )
225
+ {
226
+ if ( type == LogType . Error || type == LogType . Exception )
227
+ {
228
+ errorLogMessages . Add ( $ "{ logString } { Eol } { stackTrace } ") ;
229
+ }
230
+ }
231
+
232
+ private static void BackupLastBuild ( string buildPath )
211
233
{
212
234
if ( Directory . Exists ( buildPath ) )
213
235
{
@@ -342,6 +364,12 @@ private static void ReportSummary(BuildSummary summary)
342
364
$ "Size: { summary . totalSize . ToString ( ) } bytes{ Eol } " +
343
365
$ "{ Eol } ";
344
366
367
+ if ( errorLogMessages . Count > 0 )
368
+ {
369
+ summaryText += $ "### Error log messages: ###{ Eol } ";
370
+ summaryText += string . Join ( Eol , errorLogMessages ) ;
371
+ }
372
+
345
373
if ( summary . totalErrors == 0 )
346
374
{
347
375
Log ( summaryText ) ;
@@ -421,6 +449,18 @@ private static void Log(string message)
421
449
}
422
450
}
423
451
452
+ private static void LogWarning ( string message )
453
+ {
454
+ if ( Application . isBatchMode )
455
+ {
456
+ Console . WriteLine ( message ) ;
457
+ }
458
+ else
459
+ {
460
+ Debug . LogWarning ( message ) ;
461
+ }
462
+ }
463
+
424
464
private static void LogError ( string message )
425
465
{
426
466
if ( Application . isBatchMode )
0 commit comments