Skip to content

Commit aebe343

Browse files
committed
Merge branch 'master' into 2021.3-urp
# Conflicts: # Packages/manifest.json # Packages/packages-lock.json # ProjectSettings/ProjectVersion.txt
2 parents 66613b9 + 4f683b3 commit aebe343

File tree

18 files changed

+677
-216
lines changed

18 files changed

+677
-216
lines changed

.github/workflows/upgrade-unity.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
git fetch origin master
8383
git merge FETCH_HEAD
8484
git push
85+
git log -1
8586
8687
# Unity 2020 cache is not compatible with older versions
8788
- name: Unity Library Cache 2020 or higher

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"visualstudiotoolsforunity.vstuc"
4+
]
5+
}

.vscode/launch.json

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
{
2-
// Needed for debugging with VS Code
3-
// Use IntelliSense to learn about possible attributes.
4-
// Hover to view descriptions of existing attributes.
5-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
6-
"version": "0.2.0",
7-
"configurations": [
8-
{
9-
"name": "Unity Editor",
10-
"type": "unity",
11-
"path": "${workspaceFolder}/Library/EditorInstance.json",
12-
"request": "launch"
13-
},
14-
{
15-
"name": "Windows Player",
16-
"type": "unity",
17-
"request": "launch"
18-
},
19-
{
20-
"name": "OSX Player",
21-
"type": "unity",
22-
"request": "launch"
23-
},
24-
{
25-
"name": "Linux Player",
26-
"type": "unity",
27-
"request": "launch"
28-
},
29-
{
30-
"name": "iOS Player",
31-
"type": "unity",
32-
"request": "launch"
33-
},
34-
{
35-
"name": "Android Player",
36-
"type": "unity",
37-
"request": "launch"
38-
},
39-
{
40-
"name": "Xbox One Player",
41-
"type": "unity",
42-
"request": "launch"
43-
},
44-
{
45-
"name": "PS4 Player",
46-
"type": "unity",
47-
"request": "launch"
48-
},
49-
{
50-
"name": "SwitchPlayer",
51-
"type": "unity",
52-
"request": "launch"
53-
}
54-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Unity Editor",
6+
"type": "unity",
7+
"path": "${workspaceFolder}/Library/EditorInstance.json",
8+
"request": "launch"
9+
},
10+
{
11+
"name": "Windows Player",
12+
"type": "unity",
13+
"request": "launch"
14+
},
15+
{
16+
"name": "OSX Player",
17+
"type": "unity",
18+
"request": "launch"
19+
},
20+
{
21+
"name": "Linux Player",
22+
"type": "unity",
23+
"request": "launch"
24+
},
25+
{
26+
"name": "iOS Player",
27+
"type": "unity",
28+
"request": "launch"
29+
},
30+
{
31+
"name": "Android Player",
32+
"type": "unity",
33+
"request": "launch"
34+
},
35+
{
36+
"name": "Xbox One Player",
37+
"type": "unity",
38+
"request": "launch"
39+
},
40+
{
41+
"name": "PS4 Player",
42+
"type": "unity",
43+
"request": "launch"
44+
},
45+
{
46+
"name": "SwitchPlayer",
47+
"type": "unity",
48+
"request": "launch"
49+
},
50+
{
51+
"name": "Attach to Unity",
52+
"type": "vstuc",
53+
"request": "attach"
54+
}
55+
]
5556
}

.vscode/settings.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
{
2-
"files.exclude":
3-
{
4-
"**/.DS_Store":true,
5-
"**/.git":true,
6-
"**/.gitmodules":true,
7-
"**/*.pidb":true,
8-
"**/*.suo":true,
9-
"**/*.user":true,
10-
"**/*.userprefs":true,
11-
"**/*.unityproj":true,
12-
"**/*.meta":true,
13-
"Library/":true,
14-
"library/":true,
15-
"obj/":true,
16-
"Obj/":true,
17-
"temp/":true,
18-
"Temp/":true
19-
}
2+
"files.exclude": {
3+
"**/.DS_Store": true,
4+
"**/.git": true,
5+
"**/.gitmodules": true,
6+
"**/*.pidb": true,
7+
"**/*.suo": true,
8+
"**/*.user": true,
9+
"**/*.userprefs": true,
10+
"**/*.unityproj": true,
11+
"**/*.meta": true,
12+
"Library/": true,
13+
"library/": true,
14+
"obj/": true,
15+
"Obj/": true,
16+
"temp/": true,
17+
"Temp/": true
18+
},
19+
"dotnet.preferCSharpExtension": true,
20+
"dotnet.defaultSolution": "UnityWebGL-LoadingTest.sln"
2021
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
namespace Supyrb
1818
{
19+
/// <summary>
20+
/// Add commands to the WebGL bridge to expose them to the browser console
21+
/// </summary>
1922
public partial class WebGlBridge
2023
{
2124
/// <summary>

Assets/Plugins/WebGL/WebGLTools/WebGlPlugins.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public static class WebGlPlugins
2525
[DllImport("__Internal")]
2626
private static extern void _AddTimeTrackingEvent(string eventName);
2727
[DllImport("__Internal")]
28+
private static extern void _AddFpsTrackingEvent(float fps);
29+
[DllImport("__Internal")]
2830
private static extern void _ShowInfoPanel();
2931
[DllImport("__Internal")]
3032
private static extern void _HideInfoPanel();
@@ -68,6 +70,15 @@ public static void AddTimeTrackingEvent(string eventName)
6870
#endif
6971
}
7072

73+
public static void AddFpsTrackingEvent(float fps)
74+
{
75+
#if UNITY_WEBGL && !UNITY_EDITOR
76+
_AddFpsTrackingEvent(fps);
77+
#else
78+
Debug.Log($"{nameof(WebGlPlugins)}.{nameof(AddFpsTrackingEvent)} called with {fps:0.00}");
79+
#endif
80+
}
81+
7182
/// <summary>
7283
/// Show the info panel in the top right corner
7384
/// By default triggered by <see cref="WebGlTimeTracker"/> in Awake

Assets/Plugins/WebGL/WebGLTools/WebGlPlugins.jslib

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ var WebGlPlugins =
4949
console.log('Time tracker event ' +eventNameText +': ' + currentTimeRounded + 'ms');
5050
},
5151

52+
_AddFpsTrackingEvent: function(fps) {
53+
if(typeof onFpsTrackingEvent !== 'undefined') {
54+
onFpsTrackingEvent(fps);
55+
}
56+
},
57+
5258
_ShowInfoPanel: function () {
5359
if(typeof setInfoPanelVisible !== 'undefined') {
5460
setInfoPanelVisible(true);

Assets/Plugins/WebGL/WebGLTools/WebGlTimeTracker.cs

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// --------------------------------------------------------------------------------------------------------------------
1010

1111
using System;
12+
using System.Diagnostics;
1213
using UnityEngine;
1314

1415
namespace Supyrb
@@ -21,15 +22,25 @@ namespace Supyrb
2122
[DefaultExecutionOrder(-100)]
2223
public class WebGlTimeTracker : MonoBehaviour
2324
{
24-
[SerializeField]
25+
[SerializeField]
2526
private bool showInfoPanelByDefault = true;
26-
27+
2728
[SerializeField]
2829
private bool trackAwakeTime = true;
29-
30+
3031
[SerializeField]
3132
private bool trackStartTime = true;
3233

34+
[Header("FPS Tracking")]
35+
[SerializeField]
36+
private bool trackFps = true;
37+
38+
[SerializeField]
39+
private float updateInterval = 0.5f;
40+
41+
private Stopwatch stopWatch;
42+
private int lastFrameCount;
43+
3344
private void Awake()
3445
{
3546
if (showInfoPanelByDefault)
@@ -40,11 +51,18 @@ private void Awake()
4051
{
4152
WebGlPlugins.HideInfoPanel();
4253
}
43-
54+
55+
if(trackFps)
56+
{
57+
WebGlPlugins.AddFpsTrackingEvent(0);
58+
}
59+
4460
if (trackAwakeTime)
4561
{
4662
WebGlPlugins.AddTimeTrackingEvent("Awake");
4763
}
64+
65+
stopWatch = Stopwatch.StartNew();
4866
}
4967

5068
private void Start()
@@ -54,5 +72,32 @@ private void Start()
5472
WebGlPlugins.AddTimeTrackingEvent("Start");
5573
}
5674
}
75+
76+
private void Update()
77+
{
78+
if(!trackFps)
79+
{
80+
this.enabled = false;
81+
return;
82+
}
83+
84+
if(stopWatch.Elapsed.TotalSeconds > updateInterval)
85+
{
86+
var currentFrameCount = Time.frameCount;
87+
var frameCount = currentFrameCount - lastFrameCount;
88+
float fps = (float)(frameCount / stopWatch.Elapsed.TotalSeconds);
89+
WebGlPlugins.AddFpsTrackingEvent(fps);
90+
stopWatch.Restart();
91+
lastFrameCount = currentFrameCount;
92+
}
93+
}
94+
95+
private void OnApplicationPause(bool pauseStatus) {
96+
if (pauseStatus) {
97+
stopWatch.Stop();
98+
} else {
99+
stopWatch.Start();
100+
}
101+
}
57102
}
58103
}

0 commit comments

Comments
 (0)