Skip to content

Commit ae685ae

Browse files
committed
Improve flags used for min build size
Suggestions taken from here: https://discussions.unity.com/t/webgl-builds-for-mobile/711925/130 For the ones that are easily exposed in the player settings, and are never changed for the different build targets, I didn't explicitly set them again in code.
1 parent e2014db commit ae685ae

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Assets/Scripts/Editor/BuildScript.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,19 @@ public static void Build(string[] args)
129129
buildPlayerOptions.options |= BuildOptions.CompressWithLz4HC;
130130
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;
131131
SetWebGlOptimization(CodeOptimizationSize);
132+
// Off by default, but just to be sure, see https://docs.unity3d.com/Manual/webgl-embeddedresources.html
133+
PlayerSettings.WebGL.useEmbeddedResources = false;
134+
PlayerSettings.WebGL.threadsSupport = false;
135+
// ASTC has the smallest texture sizes
136+
EditorUserBuildSettings.webGLBuildSubtarget = WebGLTextureSubtarget.ASTC;
137+
132138
#if UNITY_2022_1_OR_NEWER
133139
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
134140
#endif
141+
#if UNITY_6000_0_OR_NEWER
142+
// Reduces build size and is widely supported
143+
PlayerSettings.WebGL.wasm2023 = true;
144+
#endif
135145
#if UNITY_2021_2_OR_NEWER
136146
PlayerSettings.SetIl2CppCompilerConfiguration(namedBuildTarget, Il2CppCompilerConfiguration.Master);
137147
#else

0 commit comments

Comments
 (0)