Skip to content

Instantly share code, notes, and snippets.

@De-Panther
De-Panther / UnityLoaderCompatibilityCheck.js
Last active February 27, 2021 00:42
Unity WebGL on mobile - Code snippet for patching UnityLoader.compatibilityCheck() so it won't show popup message on mobile. Works in Unity 2018 and 2019. Unity 2020 switched templates and don't need it.
UnityLoader.compatibilityCheck = function (unityInstance, onsuccess, onerror) {
if (!UnityLoader.SystemInfo.hasWebGL) {
unityInstance.popup('Your browser does not support WebGL',
[{text: 'OK', callback: onerror}]);
} else {
onsuccess();
}
}
// now you can call ... var unityInstance = UnityLoader.instantiate( ...
@De-Panther
De-Panther / load_spectorjs_in_dev_console.js
Last active January 30, 2024 06:23
Code snippet for loading SpectorJS in WebGL page. Copy this code to the development console of a web page with WebGL content. Make sure that you are posting it in the right context(if the canvas is inside an iframe).
var newScript = document.createElement("script");
newScript.onload = function() {
var spector = new SPECTOR.Spector();
spector.displayUI();
};
document.head.appendChild(newScript);
newScript.src = "https://spectorcdn.babylonjs.com/spector.bundle.js";