Skip to content

Commit 397ef63

Browse files
committed
Merge branch 'master' of https://github.com/JohannesDeml/UnityWebGL-LoadingTest into 2021.3-urp
2 parents d6cecd9 + c7471d1 commit 397ef63

File tree

5 files changed

+79
-39
lines changed

5 files changed

+79
-39
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@v3
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: 34 additions & 23 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
@@ -107,15 +109,15 @@ jobs:
107109
- name: Set upgrade name
108110
id: upgrade_name
109111
run: |
110-
if [[ "$URP_BRANCH" == "true" ]]
112+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
113+
if [[ "$BRANCH_NAME" == *"urp"* ]]
111114
then
112115
echo "NAME=$UNITY_VERSION-urp" >> $GITHUB_OUTPUT
113116
else
114117
echo "NAME=$UNITY_VERSION" >> $GITHUB_OUTPUT
115118
fi
116119
env:
117120
UNITY_VERSION: ${{ inputs.unityVersion }}
118-
URP_BRANCH: ${{ inputs.urp }}
119121

120122
- name: Log variables
121123
run: |
@@ -124,10 +126,11 @@ jobs:
124126
125127
- name: Build project
126128
if: ${{ !inputs.tagsOnly }}
127-
# TODO change this back to v3 once manual exit is supported there
128-
uses: game-ci/unity-builder@main
129+
uses: game-ci/unity-builder@v4
129130
env:
130131
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
132+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
133+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
131134
with:
132135
buildMethod: UnityBuilderAction.UnityPackageScripts.UpgradeAllPackagesToVerifiedVersion
133136
customParameters: ${{ inputs.customParameters }}
@@ -164,22 +167,30 @@ jobs:
164167
- name: Add tags
165168
if: ${{ inputs.createTags || inputs.tagsOnly }}
166169
run: |
167-
if [[ "$URP_BRANCH" == "true" ]]
170+
# Extract the first four characters of UNITY_VERSION
171+
UNITY_YEAR=${UNITY_VERSION:0:4}
172+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
173+
174+
TAG_PREFIX=$UNITY_VERSION
175+
if [[ "$BRANCH_NAME" == *"urp"* ]]
176+
then
177+
TAG_PREFIX=$UNITY_VERSION-urp
178+
fi
179+
180+
if [[ "$UNITY_YEAR" < "2023" ]]
168181
then
169-
git tag -a -f $UNITY_VERSION-urp-webgl1 -m "[Automated workflow] Created by upgrade-unity"
170-
git tag -a -f $UNITY_VERSION-urp-webgl2 -m "[Automated workflow] Created by upgrade-unity"
171-
git tag -a -f $UNITY_VERSION-urp-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
182+
git tag -a -f $TAG_PREFIX-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
183+
git tag -a -f $TAG_PREFIX-webgl1 -m "[Automated workflow] Created by upgrade-unity"
172184
else
173-
git tag -a -f $UNITY_VERSION-minsize-webgl1 -m "[Automated workflow] Created by upgrade-unity"
174-
git tag -a -f $UNITY_VERSION-webgl1 -m "[Automated workflow] Created by upgrade-unity"
175-
git tag -a -f $UNITY_VERSION-webgl2 -m "[Automated workflow] Created by upgrade-unity"
176-
# Push tags in between - pushing more than 3 tags won't trigger tag workflows
177-
git push origin -f --tags
178-
git tag -a -f $UNITY_VERSION-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
185+
git tag -a -f $TAG_PREFIX-minsize-webgl2 -m "[Automated workflow] Created by upgrade-unity"
179186
fi
187+
# Push tags in between - pushing more than 3 tags won't trigger tag workflows
188+
git push origin -f --tags
189+
190+
git tag -a -f $TAG_PREFIX-webgl2 -m "[Automated workflow] Created by upgrade-unity"
191+
git tag -a -f $TAG_PREFIX-webgl2-debug -m "[Automated workflow] Created by upgrade-unity"
180192
181193
git push origin -f --tags
182194
env:
183195
UNITY_VERSION: ${{ inputs.unityVersion }}
184-
URP_BRANCH: ${{ inputs.urp }}
185196

Assets/Scripts/Editor/BuildScript.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ public static void Build(string[] args)
135135
{
136136
PlayerSettings.SetGraphicsAPIs(BuildTarget.WebGL, new[] { GraphicsDeviceType.OpenGLES2, GraphicsDeviceType.OpenGLES3 });
137137
}
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
138145
}
139146

140147
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/WebGLTemplates/Develop/debug-console.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ if (getCookie("addTimestamp") === "false") {
2121
addTimestamp = false;
2222
}
2323

24-
initializeToggleButton(false);
24+
const urlParams = new URLSearchParams(window.location.search);
25+
const debugParam = urlParams.get('debug');
26+
const debug = debugParam === 'true';
27+
28+
initializeToggleButton(debug);
2529
initializeDebugConsole();
2630

2731

0 commit comments

Comments
 (0)