Skip to content

Instantly share code, notes, and snippets.

@De-Panther
Last active February 27, 2021 00:42
Show Gist options
  • Save De-Panther/f08cb4902bd21ee403d579a12510be2c to your computer and use it in GitHub Desktop.
Save De-Panther/f08cb4902bd21ee403d579a12510be2c to your computer and use it in GitHub Desktop.
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( ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment