To deploy a Web build, you must configure your server and make sure you’re using the correct response headers, so that the browser receives a proper response and processes it correctly.
Unity には、サーバーの設定方法に影響する主な設定が 2 つあります。
Choose the compression type from the Web Player Settings window (menu: Edit > Project Settings > Player, then select Web and expand the Publishing Settings section):
圧縮形式 | 説明 |
---|---|
gzip | デフォルト設定。gzip ファイルは Brotli ファイルより大きいですが、ビルドにかかる時間が短く、http と https の両方に対しすべてのブラウザによってネイティブにサポートされています。 |
Brotli | Brotli は最も高い圧縮率を得られます。Brotli 圧縮ファイルは gzip よりも著しく小さくできますが、圧縮に長い時間がかかり、リリースビルドでの反復時間を増加します。Chrome と Firefox のみが、https 全体で Brotli 圧縮をネイティブにサポートします。 |
Disabled | 圧縮を無効にします。後処理スクリプトで独自の圧縮を実装する場合は、このオプションを使用してください。また、ホスティングサーバーで静的な圧縮を使用する予定の場合にも使用する必要があります。 |
For more information on browser support for selected compression methods, refer to the documentation on Web browser compatibility.
You might need to adjust your server configuration to match your specific build setup. In particular, there might be issues if you already have another server-side configuration to compress hosted files, which could interfere with this setup. To make the browser perform decompression natively while it downloads your application, append a Content-Encoding header to the server response. This header must correspond to the type of compression Unity uses at build time. For code samples, refer to Server Configuration Code Samples.
Decompression Fallback (解凍のフォールバック) オプションは、Unity が自動的に JavaScript のデコンプレッサーをビルドに埋め込むことを可能にします。このデコンプレッサーは、選択した圧縮方式に対応しており、ブラウザーがコンテンツの解凍に失敗した場合にコンテンツを解凍します。
Enable decompression fallback from the Player Settings window (menu: Edit > Project Settings > Player, then select Web and expand the Publishing Settings section).
Decompression Fallback を有効にすると、Unity はビルドファイルに .unityweb
という拡張子を付けます。
サーバー設定の経験が少ない場合や、サーバー設定が利用できない場合は、Decompression Fallback の使用を検討してください。
ノート: このオプションを使用すると、ローダーサイズが大きくなり、ビルドファイルのロードスキームの効率が悪くなります。
Decompression Fallback オプションは、デフォルトでは無効になっています。そのため、デフォルトでは、ビルドファイルの拡張子は、選択した圧縮方法に対応しています。
There are two compression methods to choose from: gzip or Brotli. For further information refer to the compression format section.
Unity のビルドファイルをダウンロード中にブラウザーがネイティブに解凍できるようにするには、適切な HTTP ヘッダーを付けて圧縮ファイルを提供するようにウェブサーバーを設定する必要があります。これをネイティブブラウザー解凍といいます。これは、JavaScript の解凍フォールバックよりも高速で、アプリケーションの起動時間を短縮できるという利点があります。
ネイティブのブラウザー解凍の設定方法は、使用するウェブサーバーによって異なります。コードサンプルについては、サーバー設定コードサンプル を参照してください。
Content-Encoding ヘッダーは、Unity が圧縮ファイルに使用した圧縮の種類をブラウザーに伝えます。これにより、ブラウザーはファイルをネイティブに解凍することができます。
Content-Encoding 応答ヘッダーに、Player 設定で選択した圧縮方式を設定します。
圧縮形式 | ファイル拡張子 | レスポンスヘッダー |
---|---|---|
gzip | .gz | Content-Encoding: gzip |
Brotli | .br | Content-Encoding: br |
WebAssembly ストリーミングでは、ブラウザーが WebAssembly コードをダウンロードしている間にコンパイルすることができます。これにより、ロード時間が大幅に改善されます。
WebAssembly ストリーミングコンパイルを機能させるには、サーバーが application/wasm
MIME タイプの WebAssembly ファイルを返す必要があります。
WebAssembly ストリーミングを使用するには、Content-Type: application/wasm
応答ヘッダーを使用して WebAssembly ファイルを提供する必要があります。
Content-Type ヘッダーは、コンテンツがどのメディアタイプであるかをサーバーに通知します。この値は、WebAssembly ファイルに対して application/wasm
に設定する必要があります。
ファイル拡張子 | レスポンスヘッダー |
---|---|
.wasm、.wasm.gz、.wasm.br | Content-Type: application/wasm |
ノート: WebAssembly ストリーミングは JavaScript の解凍と一緒には動作しません (Decompression Fallback オプションが有効な場合)。このような場合、ダウンロードされたWebAssembly ファイルは最初に JavaScript のデコンプレッサーを通過しなければならず、そのためブラウザーはダウンロード中にストリーミングすることができません。
ファイルに JavaScript が含まれている場合は、application/javascript
Content-Type ヘッダーを追加する必要があります。サーバーによっては、このヘッダーが自動的に含まれている場合もありますが、そうでない場合もあります。
ファイル拡張子 | レスポンスヘッダー |
---|---|
.js、.js.gz、js.br | Content-Type: application/javascript |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.