When I try to run my Unity project with WebGL building on localserver IIS or Tomcat, it gets stuck like this:
(the loading page is open successfully, but progress bar does not move)
I have already added the config file for IIS, and there is no error when the browser (both Firefox and Chrome) open the index. It seems that the loading pages opened in browser are the same with and without localhost web server.
In some situations the loading can succeed:
1.directly choose "Build and Run" in Unity Engine, and the web page can successfully run the game.
2.once the building process failed with an error(a file cannot be deleted). I tried the semi-finished building project in the Temp folder of project root, and it successfully worked. But later I copied that folder to another place, it stuck on loading page again.
the Unity version is 2020.
How can I solve the problem?
The best way to view the WebGL Player locally is to use Unity's Build And Run option (menu: File > Build And Run). Unity uses a local web server to host your build, and opens it from a localhost URL. Alternatively, you can use a custom local web server with properly configured response headers.
In version 2021.2, Unity marked support for the WebGL 1 Graphics API as deprecated. In Unity 2021.2, there are no changes in behavior and Unity still includes the WebGL 1 Graphics API if you enable the Auto Graphics API Player Setting.
It may still work, especially on high-end devices, but many current devices are not powerful enough and don't have enough memory to support Unity WebGL content well.
For anyone trying this, disabling compression in player settings worked for me (Unity 2020.1.2f1) Go to Build settintgs -> Player Settings -> Publish settings -> Compression format: disable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With