0
\$\begingroup\$

If player's browser don't support WebGL, I want to redirect Web Player version. I think it's possible in UnityLoader.js file but how?

function CompatibilityCheck(){hasWebGL?mobile?confirm("Please note that Unity WebGL is not currently supported on mobiles. Press Ok if you wish to continue anyway.")||window.history.back():-1==browser.indexOf("Firefox")&&-1==browser.indexOf("Chrome")&&-1==browser.indexOf("Safari")&&(confirm("Please note that your browser is not currently supported for this Unity WebGL content. Try installing Firefox, or press Ok if you wish to continue anyway.")||window.history.back()):(alert("You need a browser which supports WebGL to run this content. Try installing Firefox."),window.history.back())}

I just want to add a URL redirect here.

\$\endgroup\$
1
\$\begingroup\$

Just add this to the bottom of the HTML page that Unity generates for you BEFORE the Module declaration and UnityLoader.js is loaded (I wouldn't hack the UnityLoader.js file because it'll get overwritten every time you do a build).

<script>
    if (!window.WebGLRenderingContext) {
        window.location = "http://whatever.com";
    }
</script>

So it would look like this at the bottom of your index.html

<script>
        if (!window.WebGLRenderingContext) {
            window.location = "http://whatever.com";
        }
    </script>

<script type='text/javascript'>
  var Module = {
    TOTAL_MEMORY: 1610612736,
    errorhandler: null,         // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    compatibilitycheck: null,
    dataUrl: "Release/Project.data",
    codeUrl: "Release/Project.js",
    memUrl: "Release/Project.mem",

  };
</script>
<script src="Release/UnityLoader.js"></script>
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.