官方说明
(1):WebAssembly 串流的服务器配置 - Unity 手册
(2):Unity - Manual: Server configuration code samples
下面以 nginx 部署为例
mime.types 配置文件添加 类型。
application/wasm wasm;
如图:
nginx.conf 配置文件 在http里面添加
include mime.types;
如图:
修改完成 重启nginx 服务,标头黄色警告就没有了。
Apache 只需添加文件到Build文件夹
.htaccess
内容:
# This configuration file should be uploaded to the server as "<Application Folder>/Build/.htaccess"
# This configuration has been tested with Unity 2020.1 builds, hosted on Apache/2.4
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.
# The following lines are required for builds without decompression fallback, compressed with gzip
<IfModule mod_mime.c>
<FilesMatch "[^.]+\.data.gz$">
Header set Content-Type "application/octet-stream"
Header set Content-Encoding "gzip"
</FilesMatch>
<FilesMatch "[^.]+\.js.gz$">
Header set Content-Type "application/javascript"
Header set Content-Encoding "gzip"
</FilesMatch>
<FilesMatch "[^.]+\.wasm.gz$">
Header set Content-Type "application/wasm"
Header set Content-Encoding "gzip"
</FilesMatch>
<FilesMatch "[^.]+\.gz$">
Header set Content-Encoding "gzip"
</FilesMatch>
<FilesMatch "[^.]+\.wasm$">
# Header set Content-Encoding "gzip"
Header set Content-Type "application/wasm"
</FilesMatch>
</IfModule>
IIS 配置