Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

WebGL + Webplayer

Discussion in 'WebGL' started by Little-Big-Monkey, Dec 1, 2015.

  1. Little-Big-Monkey

    Little-Big-Monkey

    Joined:
    Mar 4, 2014
    Posts:
    40
    Hello,

    I wonder if it would be possible to have a web page that load the webGL build if you use Edge or Chrome and the webplayer build for IE and Firefox ?
    All within the same page, so it would be the same URL for everyone.

    Does anyone know if it's possible and how to achieve that ?

    Thank you !
     
  2. heroichippo1

    heroichippo1

    Joined:
    Mar 30, 2015
    Posts:
    36
    Absolutely,

    you can use a script like this to do what you need.

    Code (JavaScript):
    1. // Simple Pre-Loader Example in Javascript
    2. // Redirects Google Chrome v42 User Agent to WebGL
    3. // Redirects all else to Web Player
    4. <!DOCTYPE html>
    5. <html>
    6. <body>
    7. <script>
    8. var chromeVersion = window.navigator.userAgent.match(/Chrome\/(\d+)\./);
    9. if (chromeVersion && chromeVersion[1]) {
    10.   if (parseInt(chromeVersion[1], 10) >= 42) {
    11.     window.location = "/unity/webgl";
    12.   }
    13. }
    14. window.location = "/webplayer/webplayer.html";
    15. </script>
    16. </body>
    17. </html>