前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >WebGL☀️Unity WebGL适配到各平台的教程

WebGL☀️Unity WebGL适配到各平台的教程

作者头像
星河造梦坊官方
发布2024-08-16 08:56:27
1990
发布2024-08-16 08:56:27
举报
文章被收录于专栏:星河造梦坊专栏

🟥 HTTP Response Header “Content-Type”

你应该用的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!》相同。

🟧 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.

1️⃣ Apache启用.htaccess

🚩 修改httpd.conf权限

搜索httpd.conf,找到如下代码:

代码语言:javascript
复制
Options FollowSymLinks 
AllowOverride None 

修改为 :

代码语言:javascript
复制
Options FollowSymLinks 
AllowOverride All 
🚩 加载 mod_rewrite模块

搜索httpd.conf,去掉下面的注释

代码语言:javascript
复制
LoadModule rewrite_module modules/mod_rewrite.so 

2️⃣ 增加 .htaccess 文件

这时需要你在你的网页根目录下(即index.html同级位置),添加 .htaccess 文件,文件内容如下:

代码语言:javascript
复制
# 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>

大家还有什么问题,欢迎在下方留言!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-10-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 🟥 HTTP Response Header “Content-Type”
  • 🟧 Unable to parse Build/WebGLRoaming.framework.js.gz!
    • 1️⃣ Apache启用.htaccess
      • 🚩 修改httpd.conf权限
      • 🚩 加载 mod_rewrite模块
    • 2️⃣ 增加 .htaccess 文件
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档