Skip to content

Commit 50af32a

Browse files
committed
Merge branch 'master' into 2022.1
# Conflicts: # ProjectSettings/ProjectVersion.txt
2 parents 912e085 + 140bdee commit 50af32a

33 files changed

+1121
-313
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ jobs:
2323
id: set_unity_version
2424
run: |
2525
UNITY_VERSION=$(sed -n 's/^\m_EditorVersion: //p'< ./ProjectSettings/ProjectVersion.txt)
26-
echo "::set-output name=VERSION::$UNITY_VERSION"
26+
echo "VERSION=$UNITY_VERSION" >> $GITHUB_OUTPUT
2727
2828
- name: Set tag
2929
id: set_tag
30-
run: echo "::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}"
30+
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
3131

3232
- name: Set target name
3333
id: set_build_name
34-
run: echo "::set-output name=VERSION::WebGL-${{ steps.set_tag.outputs.VERSION }}"
34+
run: echo "VERSION=WebGL-${{ steps.set_tag.outputs.VERSION }}" >> $GITHUB_OUTPUT
3535

3636
- name: Log variables
3737
run: |
@@ -61,6 +61,8 @@ jobs:
6161
6262
buildProject:
6363
name: Create Unity WebGL Build 🏗
64+
# only build with additional parameters, the tag alone should only create a release draft
65+
if: ${{ needs.variables.outputs.TAG != needs.variables.outputs.UNITY_VERSION }}
6466
needs: [ variables ]
6567
runs-on: ubuntu-latest
6668
strategy:
@@ -94,32 +96,23 @@ jobs:
9496

9597
createRelease:
9698
name: Create Github release 🐙
97-
# only run for the main build, the others will be added to the release manually
99+
# only run for the pure tag without build parameters
98100
if: ${{ needs.variables.outputs.TAG == needs.variables.outputs.UNITY_VERSION }}
99-
needs: [ variables, buildProject ]
101+
needs: [ variables ]
100102
runs-on: ubuntu-latest
101103
steps:
102-
- uses: actions/download-artifact@v3
103-
with:
104-
name: ${{ needs.variables.outputs.BUILD_NAME }}
105-
106-
- name: Zip release
107-
run: zip -r ${{ needs.variables.outputs.BUILD_NAME }}.zip ${{ needs.variables.outputs.BUILD_NAME }}
108-
109104
- name: Create Release
110105
uses: softprops/action-gh-release@v1
111106
with:
112-
files: ${{ needs.variables.outputs.BUILD_NAME }}.zip
113107
body: |
114-
# ${{ needs.variables.outputs.TAG }}
115108
## Changes
116109
*
117-
*
118110
119-
[${{ needs.variables.outputs.TAG }} Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.TAG }}/)
120-
[${{ needs.variables.outputs.TAG }}-webgl2](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.TAG }}-webgl2/)
121-
[${{ needs.variables.outputs.TAG }}-minsize Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.TAG }}-minsize/)
122-
[${{ needs.variables.outputs.TAG }}-urp Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.TAG }}-urp/)
111+
[${{ needs.variables.outputs.UNITY_VERSION }}-webgl2](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-webgl2/)
112+
[${{ needs.variables.outputs.UNITY_VERSION }}-webgl1](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-webgl1/)
113+
[${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl2 Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl2/)
114+
[${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl1 Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-urp-webgl1/)
115+
[${{ needs.variables.outputs.UNITY_VERSION }}-minsize-webgl1 Demo](https://deml.io/experiments/unity-webgl/${{ needs.variables.outputs.UNITY_VERSION }}-minsize-webgl1/)
123116
draft: true
124117

125118

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Upgrade Unity version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
unityVersion:
7+
description: 'Unity Version'
8+
required: true
9+
type: string
10+
customParameters:
11+
description: 'Custom cli arguments'
12+
required: false
13+
type: string
14+
default: '-accept-apiupdate ‑ignorecompilererrors'
15+
16+
jobs:
17+
upgrade-unity-version:
18+
name: Upgrade Unity version and packages
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
steps:
23+
- run: |
24+
echo "Upgrading to Unity Version: $UNITY_VERSION"
25+
env:
26+
UNITY_VERSION: ${{ inputs.unityVersion }}
27+
28+
- uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 0
31+
lfs: true
32+
33+
- uses: actions/cache@v3
34+
with:
35+
path: Library
36+
key: Library-WebGL
37+
restore-keys: Library-
38+
39+
- name: Build project
40+
uses: JohannesDeml/unity-builder@no-quit-parameter
41+
env:
42+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
43+
with:
44+
buildMethod: UnityBuilderAction.UnityPackageScripts.UpgradeAllPackagesToVerifiedVersion
45+
customParameters: ${{ inputs.customParameters }}
46+
unityVersion: ${{ inputs.unityVersion }}
47+
targetPlatform: WebGL
48+
buildName: ${{ needs.variables.outputs.BUILD_NAME }}
49+
allowDirtyBuild: true
50+
51+
- name: Delete build folder with elevated rights
52+
run: sudo rm -rf ./build
53+
54+
- name: Log git status
55+
run: git status
56+
57+
- name: Create Pull Request
58+
uses: peter-evans/create-pull-request@v4
59+
with:
60+
token: ${{ secrets.PR_GITHUB_TOKEN }}
61+
commit-message: "[Automated workflow] upgrade-unity to ${{ inputs.unityVersion }}"
62+
branch: "ci/upgrade-unity/${{ inputs.unityVersion }}"
63+
delete-branch: true
64+
title: "[Automated Pull Request] upgrade-unity to ${{ inputs.unityVersion }}"

Assets/Plugins/WebGL/WebGLTools.meta

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

Assets/Plugins/WebGL/WebGLTools/Attributes.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="WebGlCommandAttribute.cs">
3+
// Copyright (c) 2022 Johannes Deml. All rights reserved.
4+
// </copyright>
5+
// <author>
6+
// Johannes Deml
7+
// public@deml.io
8+
// </author>
9+
// --------------------------------------------------------------------------------------------------------------------
10+
11+
using System;
12+
using JetBrains.Annotations;
13+
14+
namespace Supyrb.Attributes
15+
{
16+
[AttributeUsage(AttributeTargets.Method)]
17+
[MeansImplicitUse]
18+
public class WebGlCommandAttribute : Attribute
19+
{
20+
public string Description { get; set; }
21+
}
22+
}

Assets/Plugins/WebGL/WebGLTools/Attributes/WebGlCommandAttribute.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Supyrb.WebGLTools",
3+
"rootNamespace": "",
4+
"references": [],
5+
"includePlatforms": [
6+
"Editor",
7+
"WebGL"
8+
],
9+
"excludePlatforms": [],
10+
"allowUnsafeCode": false,
11+
"overrideReferences": false,
12+
"precompiledReferences": [],
13+
"autoReferenced": true,
14+
"defineConstraints": [],
15+
"versionDefines": [],
16+
"noEngineReferences": false
17+
}

Assets/Plugins/WebGL/WebGLTools/Supyrb.WebGLTools.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="WebGlBridge.Commands.cs">
3+
// Copyright (c) 2022 Johannes Deml. All rights reserved.
4+
// </copyright>
5+
// <author>
6+
// Johannes Deml
7+
// public@deml.io
8+
// </author>
9+
// --------------------------------------------------------------------------------------------------------------------
10+
11+
using Supyrb.Attributes;
12+
using UnityEngine;
13+
14+
namespace Supyrb
15+
{
16+
public partial class WebGlBridge
17+
{
18+
/// <summary>
19+
/// Disable capturing all keyboard input, e.g. for using native html input fields
20+
/// Browser Usage: <code>unityGame.SendMessage("WebGL","DisableCaptureAllKeyboardInput");</code>
21+
/// </summary>
22+
[WebGlCommand(Description = "Disable unity from consuming all keyboard input")]
23+
public void DisableCaptureAllKeyboardInput()
24+
{
25+
#if !UNITY_EDITOR && UNITY_WEBGL
26+
WebGLInput.captureAllKeyboardInput = false;
27+
Debug.Log($"WebGLInput.captureAllKeyboardInput: {WebGLInput.captureAllKeyboardInput}");
28+
#endif
29+
}
30+
31+
/// <summary>
32+
/// Enable capturing all keyboard input, to make sure the game does not miss any key strokes
33+
/// Browser Usage: <code>unityGame.SendMessage("WebGL","EnableCaptureAllKeyboardInput");</code>
34+
/// </summary>
35+
[WebGlCommand(Description = "Enable unity from consuming all keyboard input")]
36+
public void EnableCaptureAllKeyboardInput()
37+
{
38+
#if !UNITY_EDITOR && UNITY_WEBGL
39+
WebGLInput.captureAllKeyboardInput = true;
40+
Debug.Log($"WebGLInput.captureAllKeyboardInput: {WebGLInput.captureAllKeyboardInput}");
41+
#endif
42+
}
43+
44+
/// <summary>
45+
/// Logs the current memory usage
46+
/// Browser Usage: <code>unityGame.SendMessage("WebGL","LogMemory");</code>
47+
/// </summary>
48+
[WebGlCommand(Description = "Logs the current memory")]
49+
public void LogMemory()
50+
{
51+
WebGlPlugins.LogMemory();
52+
}
53+
54+
/// <summary>
55+
/// Sets if the application should run while not focused.
56+
/// It is in background while another tab is focused or the console is focused
57+
/// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetApplicationRunInBackground", 1);</code>
58+
/// </summary>
59+
/// <param name="runInBackground">1 if it should run in background</param>
60+
[WebGlCommand(Description = "Application.runInBackground")]
61+
public void SetApplicationRunInBackground(int runInBackground)
62+
{
63+
Application.runInBackground = runInBackground == 1;
64+
}
65+
66+
/// <summary>
67+
/// Sets the rendering frame rate, see <see cref="Application.targetFrameRate"/>
68+
/// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetApplicationTargetFrameRate", 15);</code>
69+
/// </summary>
70+
/// <param name="targetFrameRate">frame rate to render in</param>
71+
[WebGlCommand(Description = "Application.targetFrameRate")]
72+
public void SetApplicationTargetFrameRate(int targetFrameRate)
73+
{
74+
Application.targetFrameRate = targetFrameRate;
75+
}
76+
77+
/// <summary>
78+
/// Sets the interval for fixed time updates, see <see cref="Time.fixedDeltaTime"/>
79+
/// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetTimeFixedDeltaTime", 0.02);</code>
80+
/// </summary>
81+
/// <param name="fixedDeltaTime"></param>
82+
[WebGlCommand(Description = "Time.fixedDeltaTime")]
83+
public void SetTimeFixedDeltaTime(float fixedDeltaTime)
84+
{
85+
Time.fixedDeltaTime = fixedDeltaTime;
86+
}
87+
88+
/// <summary>
89+
/// Sets the global timeScale, see <see cref="Time.timeScale"/>
90+
/// Somehow the timescale also affects the physics refresh rate on WebGL
91+
/// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetTimeTimeScale", 0.2);</code>
92+
/// </summary>
93+
/// <param name="timeScale">new timescale value</param>
94+
[WebGlCommand(Description = "Time.timeScale")]
95+
public void SetTimeTimeScale(float timeScale)
96+
{
97+
Time.timeScale = timeScale;
98+
}
99+
100+
/// <summary>
101+
/// Toggle the visibility of the info panel in the top right corner
102+
/// Browser Usage: <code>unityGame.SendMessage("WebGL", "ToggleInfoPanel");</code>
103+
/// </summary>
104+
[WebGlCommand(Description = "Toggle develop ui visibility of InfoPanel")]
105+
public void ToggleInfoPanel()
106+
{
107+
WebGlPlugins.ToggleInfoPanel();
108+
}
109+
110+
/// <summary>
111+
/// Log an example message to see if it is rendered correctly, and to see the stacktrace
112+
/// </summary>
113+
[WebGlCommand(Description = "Log an example debug message")]
114+
public void LogExampleMessage()
115+
{
116+
Debug.Log("This is an <color=#ff0000>example</color> message, showing off <color=#ff00ff>rich text</color> support!");
117+
}
118+
119+
/// <summary>
120+
/// Log a custom message to test Debug.Log in general
121+
/// </summary>
122+
/// <param name="message">Message that will be logged</param>
123+
[WebGlCommand(Description = "Log a custom message")]
124+
public void LogMessage(string message)
125+
{
126+
Debug.Log(message);
127+
}
128+
}
129+
}

Assets/Plugins/WebGL/WebGLTools/WebGlBridge.Commands.cs.meta

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

0 commit comments

Comments
 (0)