你应该用的Disable压缩打包。加载WebGL后,报错代码如下:
HTTP Response Header “Content-Type” configured incorrectly on the server for file Build/WebGLRoaming.wasm.gz , should be “application/wasm”. Startup time performance will suffer.
解决方法跟下面的 《Unable to parse Build/WebGLRoaming.framework.js.gz!》相同。
你应该使用的是Gzip压缩打包。报错代码如下:
This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header “Content-Encoding: gzip” present. Check browser Console and Devtools Network tab to debug.
搜索httpd.conf,找到如下代码:
Options FollowSymLinks
AllowOverride None
修改为 :
Options FollowSymLinks
AllowOverride All
搜索httpd.conf,去掉下面的注释
LoadModule rewrite_module modules/mod_rewrite.so
这时需要你在你的网页根目录下(即index.html同级位置),添加 .htaccess 文件,文件内容如下:
# This configuration file should be uploaded to the server as "<Application Folder>/Build/.htaccess"
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.
<IfModule mod_mime.c>
# The following lines are required for builds without decompression fallback, compressed with gzip
RemoveType .gz
AddEncoding gzip .gz
AddType application/octet-stream .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz
# The following lines are required for builds without decompression fallback, compressed with Brotli
RemoveType .br
RemoveLanguage .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br
AddType application/wasm .wasm
# The following line improves loading performance for uncompressed builds
AddType application/wasm .wasm
# Uncomment the following line to improve loading performance for gzip-compressed builds with decompression fallback
# AddEncoding gzip .unityweb
# Uncomment the following line to improve loading performance for brotli-compressed builds with decompression fallback
# AddEncoding br .unityweb
</IfModule>
大家还有什么问题,欢迎在下方留言!