Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oadingTest into 2022.3-urp
  • Loading branch information
JohannesDeml committed Aug 24, 2024
2 parents 465991b + 532f9bc commit 7ca7c23
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 50 deletions.
21 changes: 12 additions & 9 deletions Assets/Scripts/Editor/BuildScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.Compilation;
using UnityEngine;
using UnityEngine.Rendering;

Expand All @@ -32,22 +33,22 @@ public static class BuildScript
private static readonly string Eol = Environment.NewLine;
private static bool LogVerboseBatchMode = true;
private static bool LogVerboseInEditor = false;
private const string CodeOptimizationSpeed =
private static readonly string CodeOptimizationSpeed =
#if UNITY_2021_3_OR_NEWER
"runtimespeedlto";
CodeOptimizationWebGL.RuntimeSpeedLTO.ToString();
#else
"speed";
#endif
private const string CodeOptimizationSize =
private static readonly string CodeOptimizationSize =
#if UNITY_2021_3_OR_NEWER
"disksizelto";
CodeOptimizationWebGL.DiskSizeLTO.ToString();
#else
"size";
#endif

private const string CodeOptimizationBuildTimes =
private static readonly string CodeOptimizationBuildTimes =
#if UNITY_2021_3_OR_NEWER
"buildtimes";
CodeOptimizationWebGL.BuildTimes.ToString();
#else
"size";
#endif
Expand Down Expand Up @@ -124,7 +125,7 @@ public static void Build(string[] args)
buildPlayerOptions.options |= BuildOptions.CompressWithLz4HC;
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Master);
#if UNITY_2021_2_OR_NEWER
#if UNITY_2022_1_OR_NEWER
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
#endif
}
Expand All @@ -134,8 +135,10 @@ public static void Build(string[] args)
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.FullWithStacktrace;
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Debug);
SetWebGlOptimization(CodeOptimizationBuildTimes);
#if UNITY_2021_2_OR_NEWER
#if UNITY_2022_1_OR_NEWER
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
#endif
#if UNITY_2021_2_OR_NEWER
PlayerSettings.WebGL.debugSymbolMode = WebGLDebugSymbolMode.Embedded;
#else
PlayerSettings.WebGL.debugSymbols = true;
Expand All @@ -152,7 +155,7 @@ public static void Build(string[] args)
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Master);
// By default use the speed setting
SetWebGlOptimization(CodeOptimizationSpeed);
#if UNITY_2021_2_OR_NEWER
#if UNITY_2022_1_OR_NEWER
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSpeed);
#endif
}
Expand Down
25 changes: 25 additions & 0 deletions Assets/Scripts/Editor/CodeOptimizationWebGL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BuildScript.cs">
// Copyright (c) 2023 Johannes Deml. All rights reserved.
// </copyright>
// <author>
// Johannes Deml
// public@deml.io
// </author>
// --------------------------------------------------------------------------------------------------------------------

namespace UnityBuilderAction
{
/// <summary>
/// Code optimization settings for the build
/// See also <see href="https://forum.unity.com/threads/webgl-build-code-optimization-option.1058441/#post-9818385" />
/// </summary>
enum CodeOptimizationWebGL
{
BuildTimes,
RuntimeSpeed,
RuntimeSpeedLTO,
DiskSize,
DiskSizeLTO,
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Editor/CodeOptimizationWebGL.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 24 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![](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)

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

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

## Live Demos


### Built-in Renderpipeline WebGL2
Version | Size | Link
--- | --- | ---
2023.2.10f1 | 3.19 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-webgl2
2023.1.20f1 | 3.10 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-webgl2
2022.3.20f1 | 3.08 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-webgl2
2022.2.18f1 | 3.06 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-webgl2
2022.1.24f1 | 2.82 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-webgl2
2021.3.35f1 | 2.77 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-webgl2
6000.0.9f1 | 3.26 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-webgl2
2023.2.20f1 | 3.23 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-webgl2
2023.1.20f1 | 3.14 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-webgl2
2022.3.36f1 | 3.12 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-webgl2
2021.3.35f1 | 2.78 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-webgl2
2020.3.48f1 | 2.96 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-webgl2
2019.4.40f1 | 3.05 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-webgl2
2018.4.36f1 | 2.84 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-webgl2

### Built-in Renderpipeline WebGL1
Version | Size | Link
--- | --- | ---
2022.3.20f1 | 3.06 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-webgl1
2022.2.18f1 | 3.04 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-webgl1
2022.1.24f1 | 2.80 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-webgl1
2022.3.36f1 | 3.10 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-webgl1
2021.3.35f1 | 2.76 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-webgl1
2020.3.48f1 | 2.94 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-webgl1
2019.4.40f1 | 3.01 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-webgl1
2018.4.36f1 | 2.82 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-webgl1

### Built-in Renderpipeline Minimum size
Version | Size | Link
--- | --- | ---
2023.2.10f1 | 3.02 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-minsize-webgl2
2023.1.20f1 | 2.86 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-minsize-webgl2
2022.3.20f1 | 2.84 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-minsize-webgl1
2022.2.18f1 | 2.69 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-minsize-webgl1
2022.1.24f1 | 2.64 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-minsize-webgl1
2021.3.35f1 | 2.60 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-minsize-webgl1
6000.0.9f1 | 3.16 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-minsize-webgl2
2023.2.20f1 | 2.85 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-minsize-webgl2
2023.1.20f1 | 2.72 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-minsize-webgl2
2022.3.36f1 | 2.69 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-minsize-webgl1
2021.3.35f1 | 2.73 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-minsize-webgl1
2020.3.48f1 | 2.48 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-minsize-webgl1
2019.4.40f1 | 2.96 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-minsize-webgl1
2018.4.36f1 | 2.77 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-minsize-webgl1

### URP WebGL2
Version | Size | Link
--- | --- | ---
2023.2.10f1 | 6.66 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-urp-webgl2
2023.1.20f1 | 6.06 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-urp-webgl2
2022.3.20f1 | 5.76 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-urp-webgl2
2022.2.18f1 | 7.22 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-urp-webgl2
2022.1.24f1 | 6.47 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-urp-webgl2
2021.3.35f1 | 6.30 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl2
6000.0.9f1 | 7.27 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-urp-webgl2
2023.2.20f1 | 6.87 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-urp-webgl2
2023.1.20f1 | 6.25 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-urp-webgl2
2022.3.36f1 | 5.92 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-urp-webgl2
2021.3.35f1 | 6.31 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl2
2020.3.48f1 | 5.60 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-urp-webgl2
2019.4.40f1 | 5.56 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-urp-webgl2
2018.4.36f1 | 2.81 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-urp-webgl2

### URP WebGL1
Version | Size | Link
--- | --- | ---
2022.3.20f1 | 5.73 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-urp-webgl1
2022.2.18f1 | 7.08 MB | https://deml.io/experiments/unity-webgl/2022.2.18f1-urp-webgl1
2022.1.24f1 | 6.33 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-urp-webgl1
2021.3.35f1 | 6.12 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl1
2022.3.36f1 | 5.89 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-urp-webgl1
2021.3.35f1 | 6.13 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-webgl1
2020.3.48f1 | 5.44 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-urp-webgl1
2019.4.40f1 | 5.51 MB | https://deml.io/experiments/unity-webgl/2019.4.40f1-urp-webgl1
2018.4.36f1 | 2.80 MB | https://deml.io/experiments/unity-webgl/2018.4.36f1-urp-webgl1

### URP Minimum Size
Version | Size | Link
--- | --- | ---
2023.2.10f1 | 6.38 MB | https://deml.io/experiments/unity-webgl/2023.2.10f1-urp-minsize-webgl2
6000.0.9f1 | 6.51 MB | https://deml.io/experiments/unity-webgl/6000.0.9f1-urp-minsize-webgl2
2023.2.20f1 | 5.30 MB | https://deml.io/experiments/unity-webgl/2023.2.20f1-urp-minsize-webgl2
2023.1.20f1 | 5.71 MB | https://deml.io/experiments/unity-webgl/2023.1.20f1-urp-minsize-webgl2
2022.3.20f1 | 5.38 MB | https://deml.io/experiments/unity-webgl/2022.3.20f1-urp-minsize-webgl1
2022.1.24f1 | 6.06 MB | https://deml.io/experiments/unity-webgl/2022.1.24f1-urp-minsize-webgl1
2021.3.35f1 | 5.87 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-minsize-webgl1
2022.3.36f1 | 4.64 MB | https://deml.io/experiments/unity-webgl/2022.3.36f1-urp-minsize-webgl1
2021.3.35f1 | 6.11 MB | https://deml.io/experiments/unity-webgl/2021.3.35f1-urp-minsize-webgl1
2020.3.48f1 | 4.86 MB | https://deml.io/experiments/unity-webgl/2020.3.48f1-urp-minsize-webgl1



## Platform Compatibility

| Platform | Chrome | Firefox | Edge | Safari | Internet Explorer |
Expand Down

0 comments on commit 7ca7c23

Please sign in to comment.