Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity WebGL get stuck on loading page with localhost server(no errors)

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)

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?

like image 912
Azphire Avatar asked Aug 08 '20 11:08

Azphire


People also ask

How do I run Unity WebGL locally?

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.

Is Unity WebGL deprecated?

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.

Does Unity WebGL still work?

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.


1 Answers

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

like image 183
Kyn21kx Avatar answered Oct 04 '22 20:10

Kyn21kx