Skip to content

Commit bb6ffc4

Browse files
committed
Merge branch 'master' into 2022.2
# Conflicts: # Assets/Scripts/Editor/UnityPackageScripts.cs
2 parents 557b9b1 + 30356de commit bb6ffc4

File tree

7 files changed

+123
-49
lines changed

7 files changed

+123
-49
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
TAG: ${{ steps.set_tag.outputs.VERSION }}
1616
BUILD_NAME: ${{ steps.set_build_name.outputs.VERSION }}
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121
lfs: true
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Version missmatch ❌
5757
if: ${{ !startsWith(needs.variables.outputs.TAG, needs.variables.outputs.UNITY_VERSION) }}
58-
uses: actions/github-script@v3
58+
uses: actions/github-script@v4
5959
with:
6060
script: |
6161
core.setFailed('Unity version does not match tag version')
@@ -69,7 +69,7 @@ jobs:
6969
strategy:
7070
fail-fast: false
7171
steps:
72-
- uses: actions/checkout@v3
72+
- uses: actions/checkout@v4
7373
with:
7474
fetch-depth: 0
7575
lfs: true
@@ -92,9 +92,11 @@ jobs:
9292
restore-keys: Library-201x-
9393

9494
- name: Build project
95-
uses: game-ci/unity-builder@v2
95+
uses: game-ci/unity-builder@v4
9696
env:
9797
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
98+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
99+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
98100
with:
99101
buildMethod: UnityBuilderAction.BuildScript.BuildWithCommandlineArgs
100102
customParameters: -tag ${{ needs.variables.outputs.TAG }}
@@ -136,7 +138,7 @@ jobs:
136138
runs-on: ubuntu-latest
137139
steps:
138140
- name: Checkout code
139-
uses: actions/checkout@v3
141+
uses: actions/checkout@v4
140142

141143
- uses: actions/download-artifact@v3
142144
with:

.github/workflows/upgrade-unity.yml

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ on:
1414
required: false
1515
type: boolean
1616
default: true
17-
urp:
18-
description: 'URP branch'
19-
required: true
20-
type: boolean
21-
default: false
2217
tagsOnly:
2318
description: 'Only create tags'
2419
required: true
@@ -44,21 +39,28 @@ jobs:
4439
steps:
4540
- name: Log input parameter
4641
run: |
42+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
43+
44+
echo "Branch: $BRANCH_NAME"
4745
echo "Unity version: $UNITY_VERSION"
4846
echo "Create tags: $CREATE_TAGS"
49-
echo "URP branch: $URP_BRANCH"
5047
echo "Only create tags: $TAGS_ONLY"
5148
echo "Merge master into branch: $MERGE_MASTER"
5249
echo "Custom cli arguments: $CUSTOM_PARAMETERS"
50+
if [[ "$BRANCH_NAME" == *"urp"* ]]
51+
then
52+
echo "urp: true"
53+
else
54+
echo "urp: false"
55+
fi
5356
env:
5457
UNITY_VERSION: ${{ inputs.unityVersion }}
5558
CREATE_TAGS: ${{ inputs.createTags }}
56-
URP_BRANCH: ${{ inputs.urp }}
5759
TAGS_ONLY: ${{ inputs.tagsOnly }}
5860
MERGE_MASTER: ${{ inputs.mergeMaster }}
5961
CUSTOM_PARAMETERS: ${{ inputs.customParameters }}
6062

61-
- uses: actions/checkout@v3
63+
- uses: actions/checkout@v4
6264
with:
6365
fetch-depth: 0
6466
lfs: true
@@ -80,6 +82,7 @@ jobs:
8082
git fetch origin master
8183
git merge FETCH_HEAD
8284
git push
85+
git log -1
8386
8487
# Unity 2020 cache is not compatible with older versions
8588
- name: Unity Library Cache 2020 or higher
@@ -107,15 +110,15 @@ jobs:
107110
- name: Set upgrade name
108111
id: upgrade_name
109112
run: |
110-
if [[ "$URP_BRANCH" == "true" ]]
113+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
114+
if [[ "$BRANCH_NAME" == *"urp"* ]]
111115
then
112116
echo "NAME=$UNITY_VERSION-urp" >> $GITHUB_OUTPUT
113117
else
114118
echo "NAME=$UNITY_VERSION" >> $GITHUB_OUTPUT
115119
fi
116120
env:
117121
UNITY_VERSION: ${{ inputs.unityVersion }}
118-
URP_BRANCH: ${{ inputs.urp }}
119122

120123
- name: Log variables
121124
run: |
@@ -124,16 +127,19 @@ jobs:
124127
125128
- name: Build project
126129
if: ${{ !inputs.tagsOnly }}
127-
uses: JohannesDeml/unity-builder@no-quit-parameter
130+
uses: game-ci/unity-builder@v4
128131
env:
129132
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
133+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
134+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
130135
with:
131136
buildMethod: UnityBuilderAction.UnityPackageScripts.UpgradeAllPackagesToVerifiedVersion
132137
customParameters: ${{ inputs.customParameters }}
133138
unityVersion: ${{ inputs.unityVersion }}
134139
targetPlatform: WebGL
135140
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
136141
allowDirtyBuild: true
142+
manualExit: true
137143

138144
- name: Delete build folder with elevated rights
139145
if: ${{ !inputs.tagsOnly }}
@@ -162,22 +168,30 @@ jobs:
162168
- name: Add tags
163169
if: ${{ inputs.createTags || inputs.tagsOnly }}
164170
run: |
165-
if [[ "$URP_BRANCH" == "true" ]]
171+
# Extract the first four characters of UNITY_VERSION
172+
UNITY_YEAR=${UNITY_VERSION:0:4}
173+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
174+
175+
TAG_PREFIX=$UNITY_VERSION
176+
if [[ "$BRANCH_NAME" == *"urp"* ]]
177+
then
178+
TAG_PREFIX=$UNITY_VERSION-urp
179+
fi
180+
181+
if [[ "$UNITY_YEAR" < "2023" ]]
166182
then
167-
git tag -a -f $UNITY_VERSION-urp-webgl1 -m "[Automated workflow] Created by upgrade-unity"
168-
git tag -a -f $UNITY_VERSION-urp-webgl2 -m "[Automated workflow] Created by upgrade-unity"
169-
git tag -a -f $UNITY_VERSION-urp-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
183+
git tag -a -f $TAG_PREFIX-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
184+
git tag -a -f $TAG_PREFIX-webgl1 -m "[Automated workflow] Created by upgrade-unity"
170185
else
171-
git tag -a -f $UNITY_VERSION-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
172-
git tag -a -f $UNITY_VERSION-webgl1 -m "[Automated workflow] Created by upgrade-unity"
173-
git tag -a -f $UNITY_VERSION-webgl2 -m "[Automated workflow] Created by upgrade-unity"
174-
# Push tags in between - pushing more than 3 tags won't trigger tag workflows
175-
git push origin -f --tags
176-
git tag -a -f $UNITY_VERSION-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
186+
git tag -a -f $TAG_PREFIX-minsize-webgl2 -m "[Automated workflow] Created by upgrade-unity"
177187
fi
188+
# Push tags in between - pushing more than 3 tags won't trigger tag workflows
189+
git push origin -f --tags
190+
191+
git tag -a -f $TAG_PREFIX-webgl2 -m "[Automated workflow] Created by upgrade-unity"
192+
git tag -a -f $TAG_PREFIX-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
178193
179194
git push origin -f --tags
180195
env:
181196
UNITY_VERSION: ${{ inputs.unityVersion }}
182-
URP_BRANCH: ${{ inputs.urp }}
183197

Assets/Scripts/Editor/BuildScript.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace UnityBuilderAction
2323
/// <summary>
2424
/// Used for building the project through continuous integration (CI) or semi-automated through menu items
2525
/// Supports logging in the editor and highly configurable WebGL
26-
/// Modified version of <see href="https://github.com/game-ci/documentation/blob/main/example/BuildScript.cs">
27-
/// Tailored to the needs for <see href="https://github.com/JohannesDeml/UnityWebGL-LoadingTest">
26+
/// Modified version of <see href="https://github.com/game-ci/documentation/blob/main/example/BuildScript.cs" />
27+
/// Tailored to the needs for <see href="https://github.com/JohannesDeml/UnityWebGL-LoadingTest" />
2828
/// </summary>
2929
public static class BuildScript
3030
{
@@ -108,6 +108,10 @@ public static void Build(string[] args)
108108
#else
109109
PlayerSettings.WebGL.debugSymbols = true;
110110
#endif
111+
112+
#if UNITY_2022_2_OR_NEWER
113+
PlayerSettings.WebGL.showDiagnostics = true;
114+
#endif
111115
buildPlayerOptions.options |= BuildOptions.Development;
112116
}
113117
else
@@ -131,6 +135,13 @@ public static void Build(string[] args)
131135
{
132136
PlayerSettings.SetGraphicsAPIs(BuildTarget.WebGL, new[] { GraphicsDeviceType.OpenGLES2, GraphicsDeviceType.OpenGLES3 });
133137
}
138+
139+
#if UNITY_2023_1_OR_NEWER
140+
if (tagParameters.Contains("webgl1"))
141+
{
142+
Log("WebGL1 not supported anymore, choosing WebGL2 instead");
143+
}
144+
#endif
134145
}
135146

136147
break;

Assets/Scripts/Editor/BuildScriptMenu.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ public class BuildScriptMenu
2525
{
2626
"-projectPath", "",
2727
"-buildVersion", PlayerSettings.bundleVersion,
28-
"-androidVersionCode", PlayerSettings.Android.bundleVersionCode.ToString(CultureInfo.InvariantCulture)
28+
"-androidVersionCode", PlayerSettings.Android.bundleVersionCode.ToString(CultureInfo.InvariantCulture),
2929
};
3030

31+
// Unity 2023.1+ does not support webgl1 anymore
32+
#if !UNITY_2023_1_OR_NEWER
3133
[MenuItem("Tools/Build WebGL/webgl1")]
32-
public static void BuildWebGLDefault()
34+
public static void BuildWebGL1()
3335
{
3436
var parameters = new List<string>(baseParameters);
3537
string tag = $"{Application.unityVersion}-webgl1-manualBuild";
@@ -41,8 +43,8 @@ public static void BuildWebGLDefault()
4143
BuildWithParameters(parameters);
4244
}
4345

44-
[MenuItem("Tools/Build WebGL/minsize")]
45-
public static void BuildWebGLMinSize()
46+
[MenuItem("Tools/Build WebGL/minsize-webgl1")]
47+
public static void BuildWebGL1MinSize()
4648
{
4749
var parameters = new List<string>(baseParameters);
4850
string tag = $"{Application.unityVersion}-minsize-webgl1-manualBuild";
@@ -53,12 +55,13 @@ public static void BuildWebGLMinSize()
5355
SetParameterValue("-customBuildName", tag, ref parameters);
5456
BuildWithParameters(parameters);
5557
}
58+
#endif
5659

57-
[MenuItem("Tools/Build WebGL/debug")]
58-
public static void BuildWebGLDebug()
60+
[MenuItem("Tools/Build WebGL/webgl2")]
61+
public static void BuildWebGL2()
5962
{
6063
var parameters = new List<string>(baseParameters);
61-
string tag = $"{Application.unityVersion}-debug-manualBuild";
64+
string tag = $"{Application.unityVersion}-webgl2-manualBuild";
6265
SetBuildTarget(BuildTarget.WebGL, ref parameters);
6366
SetParameterValue("-autorunplayer", "true", ref parameters);
6467
SetParameterValue("-tag", tag, ref parameters);
@@ -67,11 +70,24 @@ public static void BuildWebGLDebug()
6770
BuildWithParameters(parameters);
6871
}
6972

70-
[MenuItem("Tools/Build WebGL/webgl2")]
71-
public static void BuildWebGLWebGL2()
73+
[MenuItem("Tools/Build WebGL/minsize-webgl2")]
74+
public static void BuildWebGL2MinSize()
7275
{
7376
var parameters = new List<string>(baseParameters);
74-
string tag = $"{Application.unityVersion}-webgl2-manualBuild";
77+
string tag = $"{Application.unityVersion}-minsize-webgl2-manualBuild";
78+
SetBuildTarget(BuildTarget.WebGL, ref parameters);
79+
SetParameterValue("-autorunplayer", "true", ref parameters);
80+
SetParameterValue("-tag", tag, ref parameters);
81+
SetParameterValue("-customBuildPath", $"Builds/WebGL/{tag}", ref parameters);
82+
SetParameterValue("-customBuildName", tag, ref parameters);
83+
BuildWithParameters(parameters);
84+
}
85+
86+
[MenuItem("Tools/Build WebGL/debug")]
87+
public static void BuildWebGLDebug()
88+
{
89+
var parameters = new List<string>(baseParameters);
90+
string tag = $"{Application.unityVersion}-debug-manualBuild";
7591
SetBuildTarget(BuildTarget.WebGL, ref parameters);
7692
SetParameterValue("-autorunplayer", "true", ref parameters);
7793
SetParameterValue("-tag", tag, ref parameters);

Assets/Scripts/Editor/UnityPackageScripts.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ private static void UpdatePackages()
108108

109109
string latestVersion = IncludePrereleases ?
110110
package.versions.latestCompatible :
111-
#if UNITY_2019_3_OR_NEWER
111+
#if UNITY_2022_3_OR_NEWER
112112
package.versions.recommended;
113+
#elif UNITY_2019_3_OR_NEWER
114+
package.versions.verified;
113115
#else
114116
package.versions.recommended;
115117
#endif
@@ -226,8 +228,24 @@ private static void EndUpdate(int returnValue)
226228
#if UNITY_2020_1_OR_NEWER
227229
Progress.Finish(ProgressId, returnValue == 0 ? Progress.Status.Succeeded : Progress.Status.Failed);
228230
#endif
231+
Debug.Log($"Updating unity packages finished with exit code {returnValue}");
232+
229233
if (Application.isBatchMode)
230234
{
235+
// Hack for unity-builder v3, since it is expecting a build result output
236+
Console.WriteLine(
237+
$"{Environment.NewLine}" +
238+
$"###########################{Environment.NewLine}" +
239+
$"# Build results #{Environment.NewLine}" +
240+
$"###########################{Environment.NewLine}" +
241+
$"{Environment.NewLine}" +
242+
$"Duration: 0{Environment.NewLine}" +
243+
$"Warnings: 0{Environment.NewLine}" +
244+
$"Errors: 0{Environment.NewLine}" +
245+
$"Size: 0 bytes{Environment.NewLine}" +
246+
$"{Environment.NewLine}"
247+
);
248+
231249
EditorApplication.Exit(returnValue);
232250
}
233251
else
@@ -236,8 +254,6 @@ private static void EndUpdate(int returnValue)
236254
{
237255
throw new Exception($"BuildScript ended with non-zero exitCode: {returnValue}");
238256
}
239-
240-
Debug.Log($"Successfully updated packages");
241257
}
242258
}
243259
}

Assets/WebGLTemplates/Develop/debug-console.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/// Processes all unity log messages and converts unity rich text to css styled console messages & adds a debug html debug console
2+
/// from https://github.com/JohannesDeml/UnityWebGL-LoadingTest
3+
14
let consoleDiv;
25
let debugToggle;
36
let logCounterDivs = {};
@@ -18,10 +21,6 @@ if (getCookie("addTimestamp") === "false") {
1821
addTimestamp = false;
1922
}
2023

21-
initializeToggleButton(false);
22-
initializeDebugConsole();
23-
24-
2524
function setCookie(cname, cvalue, exdays) {
2625
const d = new Date();
2726
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
@@ -602,3 +601,19 @@ function refreshTrackingDiv() {
602601
innerHtml += '</dl>';
603602
trackingDiv.innerHTML = innerHtml;
604603
}
604+
605+
// Polyfill for older browsers
606+
if (!String.prototype.replaceAll) {
607+
String.prototype.replaceAll = function(str, newStr) {
608+
if (str === '?')
609+
str = '\\\\?';
610+
return this.replace(str instanceof RegExp ? str : new RegExp(str, 'g'), newStr);
611+
}
612+
}
613+
614+
const urlParams = new URLSearchParams(window.location.search);
615+
const debugParam = urlParams.get('debug');
616+
const debug = debugParam === 'true';
617+
618+
initializeToggleButton(debug);
619+
initializeDebugConsole();

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
![Preview](./preview.png)
44

5-
[![](https://img.shields.io/github/release-date/JohannesDeml/UnityWebGL-LoadingTest.svg)](https://github.com/JohannesDeml/UnityWebGL-LoadingTest/releases) [![Tested up to Unity 2022.2](https://img.shields.io/badge/tested%20up%20to%20unity-2022.2-green.svg?logo=unity&cacheSeconds=2592000)](https://unity3d.com/get-unity/download/archive)
5+
[![](https://img.shields.io/github/release-date/JohannesDeml/UnityWebGL-LoadingTest.svg)](https://github.com/JohannesDeml/UnityWebGL-LoadingTest/releases) [![Tested up to Unity 2022.3](https://img.shields.io/badge/tested%20up%20to%20unity-2022.3-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 - 2022.2) and platforms*
7+
*Testing Unity's WebGL size and loading time for different versions (2018.4 - 2022.3) and platforms*
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/)
@@ -204,4 +204,4 @@ You can find a list of all live builds with their sizes over here: https://deml.
204204

205205
## License
206206

207-
* MIT (c) Johannes Deml - see [LICENSE](./LICENSE.md)
207+
* MIT (c) Johannes Deml - see [LICENSE](./LICENSE.md)

0 commit comments

Comments
 (0)