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. Dismiss Notice

Unity and games for the web

Discussion in 'Scripting' started by XukeLho, Sep 7, 2016.

  1. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    I'm currently working on an application (not a game) to be used on a browser. I'm using the webplayer platform. I know it is no longer being developed and will be deprecated in the next versions of Unity.
    I can't fully switch to webgl html5 because there are things I'm unable to do there yet.
    But a very curious thing happened, I'm only able to run my aplication on the mozilla firefox browser. I know support for the web player droped on all browsers, and I'm only able to test it on firefox, but I was expecting my html5 build would run on all browsers and not just on firefox, like the web build.

    Wich brings me to the question:
    Do Unity games for the web have a future? Or is this just poor coding on my side?
     
  2. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Well we can safely say that Web player is dead.
    The problem with WebGL is that it was (dont know if it still is) disabled by default in some browsers.
    It should also be noted that personally I am unable to run WebGL locally so I have to upload it to a server. Dont know why that is.
     
  3. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    What are your problems for the webgl build ?

    "
    Clearly, the web ecosystem is moving away from browser plugins and we are quickly approaching the point where no current browsers will still be able to run plugin content. Given this outlook, Unity is diverting resources into alternative web technologies and will begin the end-of-life process of the Unity Web Player plugin."

    https://blogs.unity3d.com/2015/10/08/unity-web-player-roadmap/
     
  4. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,139
    Company I work for has a webgl game out that works fine in all browsers. If your browsers are outdated, webgl might be disabled, but something like Chrome which is almost always up to date should still run it.
     
  6. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    You are all focusing on the wrong thing (or i missunderstood your words). I am aware that the web player is deprecated, and they are disabled on all browsers except mozilla firefox (I have all 4 browsers up to date).
    My issue is with the HTML5 build. Wich should work fine, but suffers from the exact same issues as the web player.
     
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    You'll have to be more specific about what those issues actually are.
     
    CrymX likes this.
  8. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,139
    I am not. You say html5 build, which is webgl in unity. As I said, we're not having issues, which means it's something on your end. Either something is outdated or you're doing something in code that some browsers don't like.

    Heck, I looked through the post and they all comment on webgl. Your best bet is create a new project with a button and see if it runs in chrome, edge, safari, and firefox. If it does, it's something in your project. If not, then something else is wrong with your browsers.

    Also try other computers and make sure it's not just the computer itself. Also note that mobile browsers still don't handle webgl that well, if at all.

    As @KelsoMRK said, if you load in chrome, what is it doing that you are saying it doesn't work. Blank screen, error? If you are on a PC, hitting F12 should bring up the web console which will let you see errors that might be occuring.

    As for your questions. Yes, unity web games will be around and continue to advance and get better with changes to tech. Is it a problem with your coding? Probably. If you built this for web player and just swapped to webgl thinking it will work, it isn't that simple. While learning about webgl, it took about a month to fine tune bits of code and find all the parts that were creating issues in our game before we could release on Facebook.
     
  9. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    I created a fresh project and placed a cube in it. Doesn't even have code. Just 3 gameobjects
    When I open it in chrome, it shows a gray square on the page. Does not load anything, as you can see in the first attached image.
    And when I open it on edge, it freezes at the loading screen. Does not even move the loading bar.

    I'm glad to know that web games are alive in html5 webgl. It was my mistake and I didn't read the posts properly.

    Oh and I've also added a print of the console and its errors in chrome
     

    Attached Files:

  10. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Have you a local server on your pc ? Can you show us the errors with the browser console ?
     
  11. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    Although this is a company PC, so I am not aware of all the stuff in here but I strongly believe there is no local server instaled here
     
  12. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    You should try uwamp, the webgl build can't run without a server, put build in the www folder and access it via the url :
    localhost/buildPath/index.html

    "For security reasons, Chrome places restrictions on scripts opened from local file: URLs, so this technique will not work. If you use Unity’s Build & Run command (menu: File > Build & Run) then the file will be temporarily hosted in a local web server and opened from a localhost URL (this avoids the security restrictions)."

    https://docs.unity3d.com/Manual/webgl-building.html
     
  13. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    I had no idea webgl builds could not be run outside of a server. Since I could run them on mozilla firefox and the previous web played also didn't require a server, I assumed there was some sort of issue (asside from not being in a server).
     
    CrymX likes this.
  14. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,139
    Ah, I get it now. You're building out and then trying to run the game straight up. I'm surprised your company doesn't have a place to host stuff from. @CrymX gave a possible solution, however you might be able to host things on a free host for a bit.

    Reading that link though, there is a way to disable chromes security for a single run if needed. Or just using the build & run seems to work as well.

    As far as Edge goes, I know it works, but Edge was always a little picky on the project.

    Way back, unity had a test you could run on browsers on webgl performance. Chrome was the lowest score by a huge margin. Firefox and Edge were both really close (at least these were my results).
     
    CrymX likes this.
  15. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    We have a server, just not a local one for me to test my apps in because this is not supose to run on a server. No longer sure if web deployment will be the way to go for me anymore, since 1 requires a server and the other is discontinued :S
    Bad news all around. Going to have to switch to a .exe instead
     
  16. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Why did you want a WebGl build if is not for a web server ?
     
  17. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    Previously (or rather currently, while I don't find a better solution), I was using a web player build, but then it got discontinued, so we decided to switch to a diferent build. So we thougth 'Webplayer is web, webgl is web, so they must be similar'. So that is why webgl was at the top of the list and just got removed.

    We are working on an (desktop) aplication that calls upon unity to do a 3D representation of objects. The unity app must be embeded within our app and they must be able to communicate with each other (call functions and send parameters, etc). We first achived this with the webplayer and are now starting to look for alternatives.