Skip to content

Commit 1a4cef3

Browse files
authored
Merge pull request #162 from De-Panther/webxr_polyfill_config
Added support for WebXR Polyfill config
2 parents 267aca0 + 519452f commit 1a4cef3

File tree

8 files changed

+17
-1
lines changed

8 files changed

+17
-1
lines changed

DebugProjects/Unity2019.4.7/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ PlayerSettings:
337337
m_TemplateCustomTags:
338338
DESCRIPTION: Complete interactive 3D scene demo made in Unity and exported to
339339
WebXR with the WebXR template of the Unity WebXR Export
340+
WEBXR_POLYFILL_CONFIG:
340341
mobileMTRendering:
341342
Android: 1
342343
iPhone: 1

MainProject/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ PlayerSettings:
331331
m_TemplateCustomTags:
332332
DESCRIPTION: Complete interactive 3D scene demo made in Unity and exported to
333333
WebXR with the WebXR template of the Unity WebXR Export
334+
WEBXR_POLYFILL_CONFIG:
334335
mobileMTRendering:
335336
Android: 1
336337
iPhone: 1

Packages/webxr/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Support for WebXR Polyfill config. Need to set window.WebXRPolyfillConfig.
10+
811
### Changed
912
- How the interoperability between JavaScript and C# works.
1013

Packages/webxr/Hidden~/WebGLTemplates/WebXR/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
onsuccess();
1919
}
2020
}
21+
%UNITY_CUSTOM_WEBXR_POLYFILL_CONFIG%
2122
var unityInstance = UnityLoader.instantiate("unityContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
2223
</script>
2324
</head>

Packages/webxr/Hidden~/WebGLTemplates/WebXR2020/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
var progressBarFull = document.querySelector("#unity-progress-bar-full");
5454
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
5555
var unityInstance = null;
56+
{{{ WEBXR_POLYFILL_CONFIG }}}
5657

5758
canvasContainer.style.width = "{{{ WIDTH }}}px";
5859
canvasContainer.style.height = "{{{ HEIGHT }}}px";

Packages/webxr/Hidden~/WebGLTemplates/WebXRFullView/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
onsuccess();
2020
}
2121
}
22+
%UNITY_CUSTOM_WEBXR_POLYFILL_CONFIG%
2223
var unityInstance = UnityLoader.instantiate("unityContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
2324
</script>
2425
</head>

Packages/webxr/Hidden~/WebGLTemplates/WebXRFullView2020/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
var progressBarFull = document.querySelector("#unity-progress-bar-full");
5555
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
5656
var unityInstance = null;
57+
{{{ WEBXR_POLYFILL_CONFIG }}}
5758

5859
#if BACKGROUND_FILENAME
5960
canvas.style.background = "url('" + buildUrl + "/{{{ BACKGROUND_FILENAME.replace(/'/g, '%27') }}}') center / cover";

Packages/webxr/Runtime/Plugins/WebGL/webxr.jspre

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ setTimeout(function () {
259259

260260
XRManager.prototype.init = function () {
261261
if (window.WebXRPolyfill) {
262-
this.polyfill = new WebXRPolyfill();
262+
if (window.WebXRPolyfillConfig) {
263+
// Configuration options can be found at https://github.com/immersive-web/webxr-polyfill#new-webxrpolyfillconfig
264+
// Added WebXR Polyfill Config option in the WebGLTemplates setting.
265+
// Can add there "window.WebXRPolyfillConfig = {...}" with the desired configuration.
266+
this.polyfill = new WebXRPolyfill(window.WebXRPolyfillConfig);
267+
} else {
268+
this.polyfill = new WebXRPolyfill();
269+
}
263270
}
264271

265272
this.attachEventListeners();

0 commit comments

Comments
 (0)