Skip to content

Commit 8db63af

Browse files
committed
Merge branch 'master' of https://github.com/JohannesDeml/UnityWebGL-LoadingTest into 2022.3
2 parents aad1ec8 + 844a167 commit 8db63af

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

.github/workflows/upgrade-unity.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
customParameters: ${{ inputs.customParameters }}
138138
unityVersion: ${{ inputs.unityVersion }}
139139
targetPlatform: WebGL
140-
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
140+
buildName: ${{ steps.upgrade_name.outputs.NAME }}
141141
allowDirtyBuild: true
142142
manualExit: true
143143

@@ -169,7 +169,7 @@ jobs:
169169
if: ${{ inputs.createTags || inputs.tagsOnly }}
170170
run: |
171171
# Extract the first four characters of UNITY_VERSION
172-
UNITY_YEAR=${UNITY_VERSION:0:4}
172+
MAJOR_VERSION=${UNITY_VERSION:0:4}
173173
BRANCH_NAME=${GITHUB_REF#refs/heads/}
174174
175175
TAG_PREFIX=$UNITY_VERSION
@@ -178,7 +178,7 @@ jobs:
178178
TAG_PREFIX=$UNITY_VERSION-urp
179179
fi
180180
181-
if [[ "$UNITY_YEAR" < "2023" ]]
181+
if [[ "$MAJOR_VERSION" < "2023" ]]
182182
then
183183
git tag -a -f $TAG_PREFIX-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
184184
git tag -a -f $TAG_PREFIX-webgl1 -m "[Automated workflow] Created by upgrade-unity"
@@ -191,6 +191,11 @@ jobs:
191191
git tag -a -f $TAG_PREFIX-webgl2 -m "[Automated workflow] Created by upgrade-unity"
192192
git tag -a -f $TAG_PREFIX-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
193193
194+
if [[ "$MAJOR_VERSION" >= "6000" ]]
195+
then
196+
git tag -a -f $TAG_PREFIX-webgpu -m "[Automated workflow] Created by upgrade-unity"
197+
fi
198+
194199
git push origin -f --tags
195200
env:
196201
UNITY_VERSION: ${{ inputs.unityVersion }}

Assets/Scripts/Editor/BuildScript.cs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Linq;
1515
using JetBrains.Annotations;
1616
using UnityEditor;
17+
using UnityEditor.Build;
1718
using UnityEditor.Build.Reporting;
1819
using UnityEngine;
1920
using UnityEngine.Rendering;
@@ -31,6 +32,25 @@ public static class BuildScript
3132
private static readonly string Eol = Environment.NewLine;
3233
private static bool LogVerboseBatchMode = true;
3334
private static bool LogVerboseInEditor = false;
35+
private const string CodeOptimizationSpeed =
36+
#if UNITY_2021_3_OR_NEWER
37+
"runtimespeedlto";
38+
#else
39+
"speed";
40+
#endif
41+
private const string CodeOptimizationSize =
42+
#if UNITY_2021_3_OR_NEWER
43+
"disksizelto";
44+
#else
45+
"size";
46+
#endif
47+
48+
private const string CodeOptimizationBuildTimes =
49+
#if UNITY_2021_3_OR_NEWER
50+
"buildtimes";
51+
#else
52+
"size";
53+
#endif
3454

3555
private static readonly string[] Secrets =
3656
{ "androidKeystorePass", "androidKeyaliasName", "androidKeyaliasPass" };
@@ -84,6 +104,7 @@ public static void Build(string[] args)
84104
#if UNITY_2021_2_OR_NEWER
85105
// Use ASTC texture compression, since we are also targeting mobile versions - Don't use this for desktop only targets
86106
buildPlayerOptions.subtarget = (int)WebGLTextureSubtarget.ASTC;
107+
var namedBuildTarget = NamedBuildTarget.WebGL;
87108
#endif
88109

89110
if (options.TryGetValue("tag", out string tagVersion) &&
@@ -93,17 +114,22 @@ public static void Build(string[] args)
93114
if (tagParameters.Contains("minsize"))
94115
{
95116
PlayerSettings.WebGL.template = "PROJECT:Release";
96-
SetWebGlOptimization("size");
117+
SetWebGlOptimization(CodeOptimizationSize);
118+
buildPlayerOptions.options |= BuildOptions.CompressWithLz4HC;
97119
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;
98120
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Master);
121+
#if UNITY_2021_2_OR_NEWER
122+
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
123+
#endif
99124
}
100125
else if (tagParameters.Contains("debug"))
101126
{
102127
PlayerSettings.WebGL.template = "PROJECT:Develop";
103-
SetWebGlOptimization("size");
104128
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.FullWithStacktrace;
105129
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Debug);
130+
SetWebGlOptimization(CodeOptimizationBuildTimes);
106131
#if UNITY_2021_2_OR_NEWER
132+
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSize);
107133
PlayerSettings.WebGL.debugSymbolMode = WebGLDebugSymbolMode.Embedded;
108134
#else
109135
PlayerSettings.WebGL.debugSymbols = true;
@@ -117,8 +143,12 @@ public static void Build(string[] args)
117143
else
118144
{
119145
PlayerSettings.WebGL.template = "PROJECT:Develop";
146+
PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.WebGL, Il2CppCompilerConfiguration.Master);
120147
// By default use the speed setting
121-
SetWebGlOptimization("speed");
148+
SetWebGlOptimization(CodeOptimizationSpeed);
149+
#if UNITY_2021_2_OR_NEWER
150+
PlayerSettings.SetIl2CppCodeGeneration(namedBuildTarget, Il2CppCodeGeneration.OptimizeSpeed);
151+
#endif
122152
}
123153

124154
List<GraphicsDeviceType> graphicsAPIs = new List<GraphicsDeviceType>();
@@ -155,7 +185,7 @@ public static void Build(string[] args)
155185
// Additional options for local builds
156186
if (!Application.isBatchMode)
157187
{
158-
if (options.TryGetValue("autorunplayer", out string autorunplayer))
188+
if (options.TryGetValue("autorunplayer", out string _))
159189
{
160190
buildPlayerOptions.options |= BuildOptions.AutoRunPlayer;
161191
}

0 commit comments

Comments
 (0)