Skip to content

Commit e006643

Browse files
committed
Merge branch 'master' of https://github.com/JohannesDeml/UnityWebGL-LoadingTest into 2022.3
2 parents 7b82179 + 532f9bc commit e006643

File tree

4 files changed

+72
-50
lines changed

4 files changed

+72
-50
lines changed

Assets/Scripts/Editor/BuildScript.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using UnityEditor;
1717
using UnityEditor.Build;
1818
using UnityEditor.Build.Reporting;
19+
using UnityEditor.Compilation;
1920
using UnityEngine;
2021
using UnityEngine.Rendering;
2122

@@ -32,22 +33,22 @@ public static class BuildScript
3233
private static readonly string Eol = Environment.NewLine;
3334
private static bool LogVerboseBatchMode = true;
3435
private static bool LogVerboseInEditor = false;
35-
private const string CodeOptimizationSpeed =
36+
private static readonly string CodeOptimizationSpeed =
3637
#if UNITY_2021_3_OR_NEWER
37-
"runtimespeedlto";
38+
CodeOptimizationWebGL.RuntimeSpeedLTO.ToString();
3839
#else
3940
"speed";
4041
#endif
41-
private const string CodeOptimizationSize =
42+
private static readonly string CodeOptimizationSize =
4243
#if UNITY_2021_3_OR_NEWER
43-
"disksizelto";
44+
CodeOptimizationWebGL.DiskSizeLTO.ToString();
4445
#else
4546
"size";
4647
#endif
4748

48-
private const string CodeOptimizationBuildTimes =
49+
private static readonly string CodeOptimizationBuildTimes =
4950
#if UNITY_2021_3_OR_NEWER
50-
"buildtimes";
51+
CodeOptimizationWebGL.BuildTimes.ToString();
5152
#else
5253
"size";
5354
#endif
@@ -124,7 +125,7 @@ public static void Build(string[] args)
124125
buildPlayerOptions.options |= BuildOptions.CompressWithLz4HC;
125126
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;
126127
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Master);
127-
#if UNITY_2021_2_OR_NEWER
128+
#if UNITY_2022_1_OR_NEWER
128129
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
129130
#endif
130131
}
@@ -134,8 +135,10 @@ public static void Build(string[] args)
134135
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.FullWithStacktrace;
135136
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Debug);
136137
SetWebGlOptimization(CodeOptimizationBuildTimes);
137-
#if UNITY_2021_2_OR_NEWER
138+
#if UNITY_2022_1_OR_NEWER
138139
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
140+
#endif
141+
#if UNITY_2021_2_OR_NEWER
139142
PlayerSettings.WebGL.debugSymbolMode = WebGLDebugSymbolMode.Embedded;
140143
#else
141144
PlayerSettings.WebGL.debugSymbols = true;
@@ -152,7 +155,7 @@ public static void Build(string[] args)
152155
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Master);
153156
// By default use the speed setting
154157
SetWebGlOptimization(CodeOptimizationSpeed);
155-
#if UNITY_2021_2_OR_NEWER
158+
#if UNITY_2022_1_OR_NEWER
156159
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSpeed);
157160
#endif
158161
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="BuildScript.cs">
3+
// Copyright (c) 2023 Johannes Deml. All rights reserved.
4+
// </copyright>
5+
// <author>
6+
// Johannes Deml
7+
// public@deml.io
8+
// </author>
9+
// --------------------------------------------------------------------------------------------------------------------
10+
11+
namespace UnityBuilderAction
12+
{
13+
/// <summary>
14+
/// Code optimization settings for the build
15+
/// See also <see href="https://forum.unity.com/threads/webgl-build-code-optimization-option.1058441/#post-9818385" />
16+
/// </summary>
17+
enum CodeOptimizationWebGL
18+
{
19+
BuildTimes,
20+
RuntimeSpeed,
21+
RuntimeSpeedLTO,
22+
DiskSize,
23+
DiskSizeLTO,
24+
}
25+
}

Assets/Scripts/Editor/CodeOptimizationWebGL.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![](https://img.shields.io/github/release-date/JohannesDeml/UnityWebGL-LoadingTest.svg)](https://github.com/JohannesDeml/UnityWebGL-LoadingTest/releases) [![Tested up to Unity 6](https://img.shields.io/badge/tested%20up%20to%20unity-6000.0-green.svg?logo=unity&cacheSeconds=2592000)](https://unity3d.com/get-unity/download/archive)
66

7-
*Testing Unity's WebGL size and loading time for different versions (2018.4 - 6000.0) and platforms*
7+
*Testing Unity's WebGL size and loading time for different versions (2018.4 - 6000.0) and settings*
88

99
* [Unity Forum Thread](https://forum.unity.com/threads/webgl-builds-for-mobile.545877/)
1010
* [Overview page of all builds](https://deml.io/experiments/unity-webgl/)
@@ -30,79 +30,62 @@
3030

3131
## Live Demos
3232

33-
3433
### Built-in Renderpipeline WebGL2
3534
Version | Size | Link
3635
--- | --- | ---
37-
2023.2.10f1 | 3.19 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-webgl2
38-
2023.1.20f1 | 3.10 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-webgl2
39-
2022.3.20f1 | 3.08 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-webgl2
40-
2022.2.18f1 | 3.06 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-webgl2
41-
2022.1.24f1 | 2.82 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-webgl2
42-
2021.3.35f1 | 2.77 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-webgl2
36+
6000.0.9f1 | 3.26 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-webgl2
37+
2023.2.20f1 | 3.23 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-webgl2
38+
2023.1.20f1 | 3.14 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-webgl2
39+
2022.3.36f1 | 3.12 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-webgl2
40+
2021.3.35f1 | 2.78 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-webgl2
4341
2020.3.48f1 | 2.96 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-webgl2
44-
2019.4.40f1 | 3.05 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-webgl2
45-
2018.4.36f1 | 2.84 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-webgl2
4642

4743
### Built-in Renderpipeline WebGL1
4844
Version | Size | Link
4945
--- | --- | ---
50-
2022.3.20f1 | 3.06 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-webgl1
51-
2022.2.18f1 | 3.04 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-webgl1
52-
2022.1.24f1 | 2.80 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-webgl1
46+
2022.3.36f1 | 3.10 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-webgl1
5347
2021.3.35f1 | 2.76 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-webgl1
5448
2020.3.48f1 | 2.94 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-webgl1
55-
2019.4.40f1 | 3.01 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-webgl1
56-
2018.4.36f1 | 2.82 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-webgl1
5749

5850
### Built-in Renderpipeline Minimum size
5951
Version | Size | Link
6052
--- | --- | ---
61-
2023.2.10f1 | 3.02 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-minsize-webgl2
62-
2023.1.20f1 | 2.86 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-minsize-webgl2
63-
2022.3.20f1 | 2.84 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-minsize-webgl1
64-
2022.2.18f1 | 2.69 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-minsize-webgl1
65-
2022.1.24f1 | 2.64 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-minsize-webgl1
66-
2021.3.35f1 | 2.60 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-minsize-webgl1
53+
6000.0.9f1 | 3.16 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-minsize-webgl2
54+
2023.2.20f1 | 2.85 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-minsize-webgl2
55+
2023.1.20f1 | 2.72 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-minsize-webgl2
56+
2022.3.36f1 | 2.69 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-minsize-webgl1
57+
2021.3.35f1 | 2.73 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-minsize-webgl1
6758
2020.3.48f1 | 2.48 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-minsize-webgl1
68-
2019.4.40f1 | 2.96 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-minsize-webgl1
69-
2018.4.36f1 | 2.77 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-minsize-webgl1
7059

7160
### URP WebGL2
7261
Version | Size | Link
7362
--- | --- | ---
74-
2023.2.10f1 | 6.66 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-urp-webgl2
75-
2023.1.20f1 | 6.06 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-urp-webgl2
76-
2022.3.20f1 | 5.76 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-urp-webgl2
77-
2022.2.18f1 | 7.22 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-urp-webgl2
78-
2022.1.24f1 | 6.47 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-urp-webgl2
79-
2021.3.35f1 | 6.30 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl2
63+
6000.0.9f1 | 7.27 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-urp-webgl2
64+
2023.2.20f1 | 6.87 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-urp-webgl2
65+
2023.1.20f1 | 6.25 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-urp-webgl2
66+
2022.3.36f1 | 5.92 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-urp-webgl2
67+
2021.3.35f1 | 6.31 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl2
8068
2020.3.48f1 | 5.60 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-urp-webgl2
81-
2019.4.40f1 | 5.56 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-urp-webgl2
82-
2018.4.36f1 | 2.81 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-urp-webgl2
8369

8470
### URP WebGL1
8571
Version | Size | Link
8672
--- | --- | ---
87-
2022.3.20f1 | 5.73 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-urp-webgl1
88-
2022.2.18f1 | 7.08 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-urp-webgl1
89-
2022.1.24f1 | 6.33 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-urp-webgl1
90-
2021.3.35f1 | 6.12 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl1
73+
2022.3.36f1 | 5.89 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-urp-webgl1
74+
2021.3.35f1 | 6.13 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl1
9175
2020.3.48f1 | 5.44 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-urp-webgl1
92-
2019.4.40f1 | 5.51 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-urp-webgl1
93-
2018.4.36f1 | 2.80 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-urp-webgl1
9476

9577
### URP Minimum Size
9678
Version | Size | Link
9779
--- | --- | ---
98-
2023.2.10f1 | 6.38 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-urp-minsize-webgl2
80+
6000.0.9f1 | 6.51 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-urp-minsize-webgl2
81+
2023.2.20f1 | 5.30 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-urp-minsize-webgl2
9982
2023.1.20f1 | 5.71 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-urp-minsize-webgl2
100-
2022.3.20f1 | 5.38 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-urp-minsize-webgl1
101-
2022.1.24f1 | 6.06 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-urp-minsize-webgl1
102-
2021.3.35f1 | 5.87 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-minsize-webgl1
83+
2022.3.36f1 | 4.64 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-urp-minsize-webgl1
84+
2021.3.35f1 | 6.11 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-minsize-webgl1
10385
2020.3.48f1 | 4.86 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-urp-minsize-webgl1
10486

10587

88+
10689
## Platform Compatibility
10790

10891
| Platform | Chrome | Firefox | Edge | Safari | Internet Explorer |

0 commit comments

Comments
 (0)