Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by PawleyBoboli · Jun 04, 2015 at 01:22 PM · webglpluginbrowser

Detection scheme for WebGL or Unity Plugin playback

Hi Folks,

Our project will be published online, and I would like to find a way to make the playback experience as seamless as possible for the end user. Is there a JavaScript or JQuery method for detecting if a browser can play a Unity WebGL project, and if it can't, redirect the browser to a page with a version that runs with the plugin? I know I can get the browser type and version but I would prefer to not rely on a list of compatible/non-compatible WebGL browsers, and instead use something smart enough to detect the browser's compatibility with WebGL.

Thanks for any leads or info. --Kevin

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by RSoj · Jun 25, 2015 at 01:03 PM

There is a function in generated file UnityConfig.js, which can tell you about browser WebGL support:

 var hasWebGL = (function ()
 {
     if (!window.WebGLRenderingContext)
     {
         // Browser has no idea what WebGL is. Suggest they
         // get a new browser by presenting the user with link to
         // http://get.webgl.org
         return 0;
     }
 
     var canvas = document.createElement('canvas');
     var gl = canvas.getContext("webgl");
     if (!gl)
     {
         gl = canvas.getContext("experimental-webgl");
         if (!gl)
         {
             // Browser could not initialize WebGL. User probably needs to
             // update their drivers or get a new browser. Present a link to
             // http://get.webgl.org/troubleshooting
             return 0;
         }
     }
     return 1;
 })();

I use it along with browser detection: To NOT run WebGL in IE, to run WebGL in Chrome, and in all other browsers I run WebPlayer as default. But if user don't have WebPlayer installed, he can choose to run in WebGL instead (if supported by browser).

My project runs nicely also in Opera WebGL, in Safari not so much.

For browser type and version detection I recommend bowser.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PawleyBoboli · Jun 25, 2015 at 02:53 PM 0
Share

This is just what I was looking for RSoj. Thanks so much for the info.

avatar image Sutee9 · Jun 26, 2015 at 09:19 AM 0
Share

Thanks so much for the answer! Very cool, almost exactly the procedure I need. And with the bowser.js script i can easily exclude mobiles and tablets, which are also not compatible with our game.

avatar image Laaevin · Feb 26, 2021 at 06:51 PM 0
Share

Bowser looks like it is exactly what I need. But this is my first time trying to use something like this. Can anyone point me in the direction of a simple tutorial on how to implement bowser in Unity? I've been googling for a while and haven't found any nice, clear instructions. (And I did look at the Unity Manual entry on Calling JavaScript functions from Unity scripts, I'm still lost on the exact steps to follow.)

avatar image Bunny83 Laaevin · Feb 27, 2021 at 12:21 AM 0
Share

a simple tutorial on how to implement bowser in Unity?

Sorry but that's something completely uweless inside Unity. You can build a Unity game / application for WebGL simply by selecting WebGL as build target. Of course your Unity installation need to have WebGL support module installed. If you use the UnityHub you can check your installation under the "Installs" tab and click "Add Modules" from the context menu.
This question as well as that Bowser framework is about pure javascript code as a Unity WebGL build can only run in a browser that supports WebGL. So the above mentioned method has to be used before any Unity content starts. This is pure web development and not related to Unity.
However all this is pretty irrelevant nowadays as most browsers do support WebGL. This question was asked at a time when WebGL was a quite new thing. Before that we have the UnityWebplayer plugin. However since google decided to drop the support for plugins for security reasons all major browsers have followed this example and the UnityWebPlayer does no longer exist. Currently if a browser does not support WebGL your Unity WebGL build simply does not load at all. What you do when the browser does not support WebGL is also pure web design and not related to Unity.
If you have a concrete question about gamedevelopment with the Unity engine, please ask a new seperate question. However questions about javascript and web design do not belong here as those are things outside of the Untiy scope. Just for the same reason questions about how to install PC hardware do not belong here, even though you need such hardware to run a Unity game.
avatar image
0

Answer by Schubkraft · Jun 11, 2015 at 03:19 PM

For now it should be pretty simple to write since the only browsers we are officially supporting are desktop Firefox and Chrome. So you only have to check for those two.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WebGL crash when certain actions ingame 0 Answers

WebGL Audio on iOS Safari 4 Answers

how to get the browser user agent in unity webgl? 1 Answer

Webgl build disables mouse wheel scroll on webpage. 4 Answers

WebGL: Scroll Camera 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges