One of the many problems I encountered happened when I tried to upload the first version of the game to my server. As you may know, Unity has abandoned the WebPlayer option in favor of the WebGL option, which is under development so there will be bugs! It was always super-easy to make the WebPlayer option work online, but with each Unity update you have to learn a new way to make the WebGL option work.
First of all, the offline version worked fine in Firefox, but when uploaded the project to the server I got the following error:
When you open the Developer Tools console, you will see the following:
- Failed to load resource: the server responded with a status of 404 (Not Found): Invoking error handler due to Uncaught unknown compression method
- Uncaught unknown compression method
- Failed to load resource: net::ERR_CONNECTION_RESET: Could not download Release/Test.datagz
- Failed to load resource: net::ERR_CONNECTION_RESET: Could not download Release/Test.jsgz
So what do you do when you encounter an error you have't seen before? You google it! And if you google these errors you will find a lot of people with the same problem. The solution seems to be to modify the .htaccess file. But in the latest version of Unity, there's no .htaccess file in the WebGL folder! The second link on Google was Unity's own documentation, which is not updated to the latest version which is 5.4, so there was no solution there either. Another solution was to contact the server provider.
After digging around on the web, I found the solution, and it was this super easy solution: What you need to do is to modify the index.html, which is the only file in the WebGL folder. So open it in Notepad or whatever program you are using. At the bottom of the file, you will see the following lines:
- dataUrl: "Release/Test.data",
- codeUrl: "Release/Test.js",
- memUrl: "Release/Test.mem",
To solve the problem you have, you just have to add gz to the end of those lines:
- dataUrl: "Release/Test.datagz",
- codeUrl: "Release/Test.jsgz",
- memUrl: "Release/Test.memgz",
If you upload the new version you should see that everything is working fine!