Search Unity

WebGL game not loading

Discussion in 'Web' started by unity_rjlakx9yE-Of0w, Nov 28, 2020.

  1. unity_rjlakx9yE-Of0w

    unity_rjlakx9yE-Of0w

    Joined:
    Apr 27, 2020
    Posts:
    4
    So I have this pretty major problem with hosting my game. Please know that I am an absolute beginner at using unity and just made my first "larger" game.

    I build my game and everything works fine, I get my files and I get my index.html. When I open it, it brings me to the page as intended and I can see the unity logo with the loading bar beneath it. The problem is the loading bar does not go up at all. It is simply stuck at the beginning. I have tried it in all browsers I have (Chrome, Firefox, Microsoft Edge and even Internet Explorer). It loads nearly all the way on Edge and Explorer is simply super cringe. However, I have no idea what this problem could be. It is not uploaded to a host and is only

    This is very important to me because it is related to my diploma project, which is a necessity to graduate high school where I live.

    Here are some screenshots:
    Chrome


    Edge


    Firefox


    Explorer


    (this one is just cringe)
    Edit: Pictures didn't work

    Edit 2: Thank you polemical for telling me to check the error messages, they are as following:

    I have no idea what any of this means but something is clearly wrong here. The blacked out parts contain my name

    Solution: Host the webpage with a local server, I used Servez. Also disable compression when building the project. Thank you to polemical and See_Sharp for helping me figure this out!
     
    Last edited: Dec 8, 2020
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Hit F12 or otherwise open the Javascript/Developer Console - hit F5/refresh the page and look at the errors you have. If you can't fix them on your own at least you'll have more info to post.
     
  3. unity_rjlakx9yE-Of0w

    unity_rjlakx9yE-Of0w

    Joined:
    Apr 27, 2020
    Posts:
    4
    I updated my post with the error messages but I understand none of them. I understand that there is a syntax error in the framework and some error with a loader but further than that I do not know.
     
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    From what I gather it's problematic to run locally without a local web server (I use Wampserver).

    You can get instructions with a search for "unity local file vs http webgl"

    Edit: if you do set one up vs. getting a specific browser working without it, you would then build to a folder like C:\wamp64\www\myproject\ - and then load it in the browser using http://localhost/myproject
     
  5. unity_rjlakx9yE-Of0w

    unity_rjlakx9yE-Of0w

    Joined:
    Apr 27, 2020
    Posts:
    4
    So I did find a local server called Servez which seems to do the trick, There are still problems though. It seems to have solved the loader problems but there is still something wrong with a framework:

    Do you understand any of this? Because I sure don't!

    Also thank you very much for helping me so far!

    Edit: it now the loading bar loads almost all the way but stops a short bit from the end
     
  6. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
  7. xuan_celestial

    xuan_celestial

    Joined:
    Jul 17, 2018
    Posts:
    18
  8. See_Sharp

    See_Sharp

    Joined:
    Mar 3, 2016
    Posts:
    74
    WebGL does require some web knowledge to get it ticking.

    First, disable the compression in the playersettings. Enabling compression requires your webserver to serve your content correctly, since you do not have a webserver running, it doesn't even serve it.

    Second: Try to do a build and run (Ctrl + B). This will host a mini webserver and open up your index.html page automatically after the build completed. This should work out of the box without compression enabled.

    Unity WebGL needs to be hosted on a webserver. If you want to use compression, and I strongly advise you to do so, you have to configure your web server to host those files with the correct content-type as described here.
     
  9. unity_rjlakx9yE-Of0w

    unity_rjlakx9yE-Of0w

    Joined:
    Apr 27, 2020
    Posts:
    4
    Disabling the compression did the trick! Thank you so much!
     
  10. MaPo3D

    MaPo3D

    Joined:
    Oct 29, 2020
    Posts:
    1
    I had the same issue. Solving by disable compression in player settings and now it works. Thank you.
     
  11. Naablet

    Naablet

    Joined:
    Jul 16, 2020
    Posts:
    1
    Hi! I'm having the same issue (meaning that there are errors when trying to run the game through WebGL build). Just to be sure that I understood the comments above correctly: when I disable the compression I also have to have a webserver for the game to run? Sorry for the noob question, still a beginner in coding and Unity.
     
  12. Raheelahmed1225

    Raheelahmed1225

    Joined:
    Nov 17, 2018
    Posts:
    2
  13. Raheelahmed1225

    Raheelahmed1225

    Joined:
    Nov 17, 2018
    Posts:
    2
    I got this error again again and again dont know to deal with it, I am new to unity and practicing through unity learn platform but it get error error and error
     
  14. regilinck

    regilinck

    Joined:
    May 30, 2018
    Posts:
    1
  15. rara

    rara

    Joined:
    Mar 30, 2013
    Posts:
    1
    I Tried turning decompression off but it didn't work
     
    hidden13isme likes this.
  16. hidden13isme

    hidden13isme

    Joined:
    Aug 29, 2022
    Posts:
    2
    I'm having the same issue.
     
  17. justlearncom

    justlearncom

    Joined:
    May 25, 2022
    Posts:
    1
  18. ankitrajdwivedi01

    ankitrajdwivedi01

    Joined:
    Aug 29, 2023
    Posts:
    5
    1. Install python server in your local machine.
    2. Build your project from unity.
    3. Navigate to your build folder
    4. open cmd in current directory.
    5. Run command for windows user : > python -m http.server and > python3 -m http.server on Mac.
    6. It shows the port number.
    7. Open any browser in your system and type localhost: portNumber in my case it is localhost:8000 hit enter your game will run locally.
     
    Last edited: Sep 28, 2023
  19. liambilly

    liambilly

    Joined:
    May 13, 2022
    Posts:
    154
    which compression tick
     
  20. Talha_140

    Talha_140

    Joined:
    Nov 30, 2022
    Posts:
    2
    image_2024-01-12_145441761.png

    I get this error while running the webgl project how can i fix this ?
     
    Last edited: Jan 12, 2024
  21. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,725
    @Talha_140 does it work when you do build and run from inside unity? or always give the above message? or is it only giving it from your webserver, or or when run on specific devices or what?