16
16
using UnityEditor ;
17
17
using UnityEditor . Build ;
18
18
using UnityEditor . Build . Reporting ;
19
+ using UnityEditor . Compilation ;
19
20
using UnityEngine ;
20
21
using UnityEngine . Rendering ;
21
22
@@ -32,22 +33,22 @@ public static class BuildScript
32
33
private static readonly string Eol = Environment . NewLine ;
33
34
private static bool LogVerboseBatchMode = true ;
34
35
private static bool LogVerboseInEditor = false ;
35
- private const string CodeOptimizationSpeed =
36
+ private static readonly string CodeOptimizationSpeed =
36
37
#if UNITY_2021_3_OR_NEWER
37
- "runtimespeedlto" ;
38
+ CodeOptimizationWebGL . RuntimeSpeedLTO . ToString ( ) ;
38
39
#else
39
40
"speed" ;
40
41
#endif
41
- private const string CodeOptimizationSize =
42
+ private static readonly string CodeOptimizationSize =
42
43
#if UNITY_2021_3_OR_NEWER
43
- "disksizelto" ;
44
+ CodeOptimizationWebGL . DiskSizeLTO . ToString ( ) ;
44
45
#else
45
46
"size" ;
46
47
#endif
47
48
48
- private const string CodeOptimizationBuildTimes =
49
+ private static readonly string CodeOptimizationBuildTimes =
49
50
#if UNITY_2021_3_OR_NEWER
50
- "buildtimes" ;
51
+ CodeOptimizationWebGL . BuildTimes . ToString ( ) ;
51
52
#else
52
53
"size" ;
53
54
#endif
@@ -124,7 +125,7 @@ public static void Build(string[] args)
124
125
buildPlayerOptions . options |= BuildOptions . CompressWithLz4HC ;
125
126
PlayerSettings . WebGL . exceptionSupport = WebGLExceptionSupport . None ;
126
127
PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Master ) ;
127
- #if UNITY_2021_2_OR_NEWER
128
+ #if UNITY_2022_1_OR_NEWER
128
129
PlayerSettings . SetIl2CppCodeGeneration ( namedBuildTarget , Il2CppCodeGeneration . OptimizeSize ) ;
129
130
#endif
130
131
}
@@ -134,8 +135,10 @@ public static void Build(string[] args)
134
135
PlayerSettings . WebGL . exceptionSupport = WebGLExceptionSupport . FullWithStacktrace ;
135
136
PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Debug ) ;
136
137
SetWebGlOptimization ( CodeOptimizationBuildTimes ) ;
137
- #if UNITY_2021_2_OR_NEWER
138
+ #if UNITY_2022_1_OR_NEWER
138
139
PlayerSettings . SetIl2CppCodeGeneration ( namedBuildTarget , Il2CppCodeGeneration . OptimizeSize ) ;
140
+ #endif
141
+ #if UNITY_2021_2_OR_NEWER
139
142
PlayerSettings . WebGL . debugSymbolMode = WebGLDebugSymbolMode . Embedded ;
140
143
#else
141
144
PlayerSettings . WebGL . debugSymbols = true ;
@@ -152,7 +155,7 @@ public static void Build(string[] args)
152
155
PlayerSettings . SetIl2CppCompilerConfiguration ( BuildTargetGroup . WebGL , Il2CppCompilerConfiguration . Master ) ;
153
156
// By default use the speed setting
154
157
SetWebGlOptimization ( CodeOptimizationSpeed ) ;
155
- #if UNITY_2021_2_OR_NEWER
158
+ #if UNITY_2022_1_OR_NEWER
156
159
PlayerSettings . SetIl2CppCodeGeneration ( namedBuildTarget , Il2CppCodeGeneration . OptimizeSpeed ) ;
157
160
#endif
158
161
}
0 commit comments