Table of contents
Unity packages WebGL PlayerSettings settings
Local server test environment configuration
overview
Take stock of the configurations Unity needs and the difficulties encountered when building the WebGL environment package
Unity packages WebGL PlayerSettings settings
Resolution and Presentation
The Resolution and Presentation interface mainly sets the resolution display of the packaged WebGL interface
The set resolution should be as consistent as possible with the resolution of the current compiler interface
Other Settings
The default setting of Unity Other Settings will see a warning after opening. The general meaning is to remind us to enable high-quality lightmap encoding and ensure WebGL 2 compatibility in the Unity WebGL build. To solve this warning, you only need to set Auto Graphics After the API automatic graphics interface is turned off, select WebGL2 in Graphics APIs to solve this warning
Publishing Settings
This is the system default Publishing setting
Among them, Compression Format is the compressed format of the packaged Build package. If you want to test in the environment of the local server, that is, 127.0.0, select Disabled. If you choose to compress, you need to decompress these files.
Select the Build package of Gzip
Select the Disabled Build package
If you choose to compress and package, then in the local test (wide area network test hen~), there will be a problem that the browser does not support decompression. The solution to this problem is still under study, so I will only explain the uncompressed ones. The problems that arise will only be reflected in the size of the package. If it is not officially launched but only tested locally, there will be no difference and there will be no problem of decompression.
All the configurations before packaging here have been completed, and the next step is to configure the local server test environment
Local server test environment configuration
After packaging, we will find that there will be a URL html in our folder, which means that our web package has been successfully packaged, so we can run our project directly by clicking on this html file
No wonder! ! !
Surely readers who have been single for decades have turned on the page
The file could not be downloaded, this browser does not support loading web pages via file:// URLs without a web server. Please use a local development web server to host Unity content, or use the Unity build and run option.
The blood-red error report that caught my eyes was like a thousand arrows piercing my heart, I took off my pants, show me this! ! !
Don't panic, come right away......
This problem is because our web package must be able to run normally in an environment supported by the server, so the next point is to come
We want to configure the server hosting status of our package body in the local environment of 127.0.0
First of all, we must configure the Windows function of our computer
1. Open the control panel
2.
3.
4.
Select all the arrows on the left of Internet Information Services and click OK
The next step is to create a new network
1. Find this computer and right click to find the management option
2. After opening, we can see the following interface. Find the Internet Information Services option under Services and Applications and click to enter
3. Find the website, right click and click to add a new website
4.
5. After clicking OK, a local path will be created
Then enter 127.0.0.1:8080 (the port number set) on our web page
If there is no accident, an accident will come
After entering the interface, we saw that the error message disappeared but did not enter our interface. According to the law of energy conservation, the error message did not disappear. He just changed a way to accompany you. When we pressed F12 to enter the web console, we found that the error message came.
We found an error in our .data file on the network, we double-click it to enter such an interface
This is because the MIME type of our website does not support parsing .data type files, so where does this .data file come from? ? ?
Friends who have such doubts must have never seen what exists in the web package packaged by Unity
There are several files in our Build package
The parsing of .data is caused by this
Then the bus to the kindergarten is about to leave~~~~~~~~~~~~~~~~~~
Let's go back to our website configuration interface and click on the website we added
Find the MIME type double-click him double-click double-click important things say three times
Add our MIME type in this interface
application/octet-stream I know you guys are too lazy to type
Click OK to add our type, and then go back to our website to find that the Newton coffin board can’t be held down. The energy conservation has disappeared. The BUG is gone.
So far, all environment configurations have been completed and the rocket has been launched successfully.
Problem inventory
Some problems were found in the test that prevented the project from running
In our project, we cannot reduce the number of file parsing, especially json, which accounts for the bulk of our parsing files.
I found a problem when parsing json after packaging. It should be that the json parsing I use is parsed by the Newtonsoft.Json.dll plug-in. When we run it after packaging, we will find that this plug-in Web cannot recognize it, so it will send us an error.
The solution to this is actually very simple to replace a parsing plug-in or directly use the API that comes with unity to parse
Click to download the analysis plug-in