Unity打包WebGL(我的配置)
目前只能用unity写一些小打小闹的玩意儿,从unity打包webgl文档里提取出一些对当下有用的并且能拿捏的了的点,暂时舍弃那些复杂或者高深的东西。
Unity打包WebGL其他注意事项
- WebGL中的纹理压缩(Build Settings中设置的纹理压缩格式值优先于Player Settings中设置的值、可以自定义单个纹理的纹理压缩格式,为单个纹理设置的值将覆盖默认的纹理压缩格式值、Build settings 中的纹理压缩在 Library 文件夹中序列化,因此,它不受版本控制的管理)
WebGL Player 设置(我的设置)
Other Settings->Rendering
- Color Space:Linear
- Auto Graphics API:WebGl2.0
- Static Batching:默认值
- Dynamic Batching:默认值
- Graphics Jobs:不勾选
- 纹理压缩格式:默认值
- Lightmap Encoding:Normal Quality
- HDR Cubemap Encoding:Normal Quality
- Lightmap Streaming Enabled:False
- Streaming Priority:默认值
- Frame Timing Stats:False
- Virtual Texturing:False
- Shader precision model:默认值
- 360 Stereo Capture:False
- Load/Store Action Debug Mode:None
Other Settings->Configuration
- Scripting Backend:Il2CPP
- API Compatibility Level:.Net Standard 2.1
- IL2CPP Code Generation:Faster runtime
- C++ Compiler Configuration:默认值
- Use incremental GC:默认值
- Allow downloads over HTTP:默认值
- Active Input Handling:Input Manager (old)
Other Settings->Shader Variant Loading
- 不理解,全默认值。
Other Settings->Script Compilation
- 不理解,全默认值。
Other Settings->Optimization
- 拿捏不了,全默认值。
Other Settings->Stack Trace
- 全None,不会看日志。
Publishing Settings
- Enable Exceptions:_None
- Compression Format:gzip
- Name Files As Hashes:False
- Decompression Fallback:不勾选
- Data caching:True
- Debug Symbols:False
- Show Diagnostics Overlay:False
- Initial Memory Size:默认值
- Memory Growth Mode:默认值
- Maximum Memory Size:默认值
- Linear Memory Growth Step:默认值
- Geometric Memory Growth Step:默认值
- Geometric Memory Growth Cap:默认值
Build Settings
- Texture Compression:Use Player Settings
- Development Build:不勾选
- Code Optimization:Speed
Unity打包webgl时nginx服务器配置
似乎2020年之后,官方文档上就一直是下面这套配置,虽然官方文档写的是样例供参考,不过不用改它也是能用的。
http {
# ...
server {
# Add the following config within http server configuration
# ...
# On-disk Brotli-precompressed data files should be served with compression enabled:
location ~ .+\.(data|symbols\.json)\.br$ {
# Because this file is already pre-compressed on disk, disable the on-demand compression on it.
# Otherwise nginx would attempt double compression.
gzip off;
add_header Content-Encoding br;
default_type application/octet-stream;
}
# On-disk Brotli-precompressed JavaScript code files:
location ~ .+\.js\.br$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding br;
default_type application/javascript;
}
# On-disk Brotli-precompressed WebAssembly files:
location ~ .+\.wasm\.br$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding br;
# Enable streaming WebAssembly compilation by specifying the correct MIME type for
# Wasm files.
default_type application/wasm;
}
# On-disk gzip-precompressed data files should be served with compression enabled:
location ~ .+\.(data|symbols\.json)\.gz$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding gzip;
default_type application/gzip;
}
# On-disk gzip-precompressed JavaScript code files:
location ~ .+\.js\.gz$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding gzip; # The correct MIME type here would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it's preferable to use MIME Type application/gzip instead.
default_type application/javascript;
}
# On-disk gzip-precompressed WebAssembly files:
location ~ .+\.wasm\.gz$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding gzip;
# Enable streaming WebAssembly compilation by specifying the correct MIME type for
# Wasm files.
default_type application/wasm;
}
}
}
0o0oo