Version: 2022.2
言語: 日本語
高度な概要
WebGL のテクスチャ圧縮

WebGL の Player 設定

This page details the Player settings specific to the WebGL platform. For a description of the general Player settings, see Player settings.

WebGL Player 設定
WebGL Player 設定

以下のセクションのプロパティが説明されています。

Note: Although the Icon panel appears on the WebGL Player settings, there are no icon settings because WebGL games don’t use icons.

For more information about WebGL Publishing Settings, see WebGL Building and Running.

Resolution and Presentation

このセクションでは、スクリーンモードとデフォルトサイズをカスタマイズできます。

Resolution section for the WebGL Player platform
Resolution section for the WebGL Player platform

Resolution

設定 機能
Default Canvas Width WebGL キャンバス要素の幅を設定します。
Default Canvas Height WebGL キャンバス要素の高さを設定します。
Run In Background これを有効にすると、キャンバスやブラウザーウィンドウがフォーカスを失ったときにもコンテンツを継続して実行できます。

WebGL Template

WebGL プロジェクトに使用するテンプレートを選択します。

  • Default ページはグレーのキャンバスにプログレスバーがあるシンプルな白いページです。
  • Minimal ページには WebGL コンテンツを実行するのに必要な定型コードのみが含まれます。
  • The PWA page has a Progressive Web App including a web manifest file and service worker code.

独自のテンプレートを指定して、完成したゲームと同様の環境でゲームを実行することができます。WebGL テンプレートの使用 を参照してください。

Splash Image

Use the Virtual Reality Splash Image setting to select a custom splash image for XR displays. For information on common Splash Screen settings, see Splash Screen.

Splash screen settings for virtual reality.
Splash screen settings for virtual reality.

Other Settings (その他の設定)

このセクションでは、以下のグループに分類されたさまざまなオプションをカスタマイズできます。

Rendering

これらの設定を使用して、WebGL プラットフォーム向けにゲームをレンダリングする方法をカスタマイズします。

WebGL プラットフォームの Rendering Player 設定
WebGL プラットフォームの Rendering Player 設定
設定 機能
Color Space Choose what color space to use for rendering: Gamma or Linear.
See Linear rendering overview for an explanation of the difference between the two.
Auto Graphics API Disable this option to manually pick and reorder the graphics APIs. By default this option is enabled, and Unity includes WebGL2.0, with WebGL1.0 as a fallback for devices where WebGL2.0 isn’t supported.
Static Batching このオプションを有効にして、静的バッチ処理を行います。
Dynamic Batching これを有効にして、ダイナミックバッチング をビルドに使用します (デフォルトでは有効になっています)。
Graphics Jobs Enable this option to instruct Unity to offload graphics tasks (render loops) to worker threads running on other CPU cores. Use it to reduce the time spent in Camera.Render on the main thread, which is often a bottleneck.
Note: This feature is experimental. It may not deliver a performance improvement for your project, and may introduce new crashes.
Texture compression format Choose DXT, ETC2, or ASTC to set the texture compression format for WebGL. For information on how to pick the right format, see Texture compression format overview and to learn how to create builds for desktop and mobile browsers from a script, see Texture Compression in WebGL.
Lightmap Encoding ライトマップのエンコードを設定するには、Low QualityNormal QualityHigh Quality のいずれかを選択します。この設定は、ライトマップのエンコードスキームと圧縮形式に影響します。
HDR Cubemap Encoding HDR キューブマップのエンコードを設定するには、Low QualityNormal QualityHigh Quality のいずれかを選択します。この設定は、HDR キューブマップのエンコードスキームと圧縮形式に影響します。
Lightmap Streaming Enabled ライトマップに Mipmap Streaming を使用するかどうかを設定します。Unity は、ライトマップを生成するときに、この設定をすべてのライトマップに適用します。
ノート: この設定を使用するには、Texture Streaming Quality 設定を有効にする必要があります。
Streaming Priority Set the priority for all lightmaps in the Mipmap Streaming system. Unity applies this setting to all lightmaps when it generates them.
Positive numbers give higher priority. Valid values range from —128 to 127.
Frame Timing Stats これを有効にすると、CPU/GPUフレームタイミング統計を収集します。
Virtual Texturing Indicates whether to enable Virtual Texturing.
Note: The Unity Editor requires a restart for this setting to take effect.
Shader precision model Controls the default precision of samplers used in shaders. See Shader data types and precision for more details.
360 Stereo Capture Indicates whether Unity can capture stereoscopic 360 images and videos. When enabled, Unity compiles additional shader variants to support 360 capture (currently only on Windows/OSX). When enabled, enable_360_capture keyword is added during the Stereo RenderCubemap call. Note that this keyword is not triggered outside the Stereo RenderCubemap function. For more information, see Stereo 360 Image and Video Capture.
Load/Store Action Debug Mode Highlights undefined pixels that might cause rendering problems in your built application. The highlighting appears only in the Game view, and your built application if you select Development Build in Build Settings. See LoadStoreActionDebugModeSettings.
Editor Only Highlights undefined pixels in the Game view, but not in your built application.

Configuration

WebGL プラットフォームの Configuration 設定
WebGL プラットフォームの Configuration 設定
Property Description
スクリプティングバックエンド 使用するスクリプティングバックエンドを選択します。スクリプトバックエンドは、Unity が Project 内の C# コードをどのようにコンパイルし、実行するかを決定します。
Mono C# コードを .NET 共通中間言語 (CIL) にコンパイルし、共通言語ランタイムを使用して CIL を実行します。詳細は Mono を参照してください。
IL2CPP Compiles C# code into CIL, converts the CIL to C++ and then compiles that C++ into native machine code, which executes directly at runtime. Refer to IL2CPP for more information.
API Compatibility Level プロジェクトで使用可能にする .NET API を選択します。この設定は、サードパーティのライブラリとの互換性に影響する可能性があります。ただし、エディター固有のコード (エディターディレクトリ内のコードや、エディター固有のアセンブリ定義内のコード) には影響しません。

ヒント: サードパーティのアセンブリに問題がある場合は、以下の API Compatibility Level セクションに提案されている方法を試してみてください。
.Net Standard 2.1 NET Standard 2.1 と互換性があります。より小さなビルドを生成し、完全なクロスプラットフォームサポートを提供します。
.Net Framework Compatible with the .NET Framework 4 (which includes everything in the .NET Standard 2.0 profile plus additional APIs). Choose this option when using libraries that access APIs not included in .NET Standard 2.0. Produces larger builds and any additional APIs available aren’t necessarily supported on all platforms. Refer to Referencing additional class library assemblies for more information.
IL2CPP Code Generation Unity が IL2CPP コード生成を管理する方法を定義します。このオプションは、IL2CPP スクリプトバックエンドを使用する場合にのみ使用できます。
Faster runtime ランタイムのパフォーマンス用に最適化されたコードを生成します。この設定はデフォルトで有効になっています。
Faster (smaller) builds ビルドサイズとイテレーションに重点を置いて最適化されたコードを生成します。生成されるコードが少なくなり、ビルドも小さくなりますが、汎用コードに関してランタイムのパフォーマンスが低下する場合があります。このオプションは、変更を加えて反復処理を行う場合など、ビルド時間の短縮が重要な場合に使用してください。
C++ Compiler Configuration IL2CPP で生成されたコードのコンパイル時に使用する C++ コンパイラーの設定を選択します。
ノート: このプロパティは、 Scripting BackendIL2CPP に設定されている場合以外は無効になります。
Use incremental GC インクリメンタルガベージコレクターを使用します。これは、ガベージコレクションを複数のフレームに分散させることで、フレーム持続時間中の、ガベージコレクション関連のスパイクを減らすものです。詳細は Automatic Memory Management を参照してください。
Allow downloads over HTTP HTTP 経由でのコンテンツのダウンロードを許可するかどうか指定します。選択可能なオプションは Not allowedAllowed in Development builds onlyAlways allowed です。デフォルトのオプションは Not allowed です。これは、より安全なプロトコルである HTTPS が推奨されるためです。
Active Input Handling ユーザーからの入力をどのように処理するか選択します。
Input Manager (old) デフォルトの Input ウィンドウを使用します。
Input System Package (New) 新しい Input システムを使用します。新しい Input System の使用を試すには、InputSystem パッケージ をインストールしてください。
Both Use both systems side by side.

Shader Variant Loading

これらの設定を使用して、ランタイムにシェーダーが使用するメモリの量を制御します。

設定 説明 
Default chunk size (MB) Sets the maximum size of compressed shader variant data chunks Unity stores in your built application for all platforms. The default is 16. Refer to Shader loading for more information.
Default chunk count 全てのプラットフォームに対して、Unity がメモリに保持する解凍チャンク数のデフォルト制限を設定します。デフォルトは 0 で、これは制限がないことを意味します。
Override このビルドターゲットの Default chunk sizeDefault chunk count のオーバーライドを有効にします。
Chunk size (MB) このビルドターゲットの Default chunk size (MB) の値をオーバーライドします。
Chunk count このビルドターゲットの Default chunk count の値をオーバーライドします。

API Compatibility Level

You can choose your mono API compatibility level for all targets. Sometimes a 3rd-party .NET library uses functionality that’s outside of your .NET compatibility level. To understand what’s going on in such cases, and how to best fix it, try following these suggestions:

  1. Windows 用 ILSpy をインストールします。
  2. Drag the .NET assemblies for the API compatilibity level that you are having issues with into ILSpy. You can find the problematic files under Frameworks/Mono/lib/mono/YOURSUBSET/.
  3. サードパーティ製のアセンブリをドラッグします。
  4. サードパーティ製のアセンブリを右クリックし、Analyze を選択します。
  5. In the analysis report, inspect the Depends on section. The report highlights anything that the 3rd-party assembly depends on, but that’s not available in the .NET compatibility level of your choice in red.

Script Compilation

WebGL プラットフォーム用のスクリプトのコンパイル設定
WebGL プラットフォーム用のスクリプトのコンパイル設定
設定 機能
Scripting Define Symbols カスタムコンパイルフラグを設定します。詳細は、プラットフォーム依存コンパイル のドキュメントを参照してください。
Additional Compiler Arguments Add entries to this list to pass additional arguments to the Roslyn compiler. Use one new entry for each additional argument.
To create a new entry, press the ‘+’ button. To remove an entry, press the ‘-’ button.
When you have added all desired arguments, click the Apply button to include your additional arguments in future compilations. The Revert button resets this list to the most recent applied state.
Suppress Common Warnings C#の警告 CS0169CS0649 を表示するには、この設定を無効にします。
Allow ‘unsafe’ Code 事前に定義されたアセンブリ (例えば Assembly-CSharp.dll) の ‘unsafe’ C# code をコンパイルするサポートを有効にします。
アセンブリ定義ファイル (.asmdef) の場合、.asmdef ファイルの 1 つをクリックし、表示されたインスペクターウィンドウでオプションを有効にします。
Use Deterministic Compilation Disable this setting to prevent compilation with the -deterministic C# flag. With this setting enabled, compiled assemblies are byte-for-byte identical each time they’re compiled.
For more information, see Microsoft’s deterministic compiler option documentation.
Enable Roslyn Analyzers この設定を無効にすると、プロジェクト内に存在する可能性のある Roslyn アナライザー DLL を使用せずに、ユーザーが作成したスクリプトをコンパイルします。

Optimization

WebGL プラットフォームの Optimization 設定
WebGL プラットフォームの Optimization 設定
Property Description
Prebake Collision Meshes ビルド時間に メッシュ に衝突データを追加します。
Keep Loaded Shaders Alive Indicates whether to prevent shaders from being unloaded.

For more information, see Shader Loading.
Preloaded Assets プレイヤーが起動時にロードするアセットの配列を設定します。
新しいアセットを追加するには、Size プロパティの値を大きくしてから、新しく表示された Element ボックス内に、ロードするアセットへの参照を設定してください。
AOT compilation options Additional options for Ahead of Time (AOT) compilation. This helps optimize the size of the built iOS player.
Strip Engine Code Enable this option if you want the Unity Linker tool to remove code for Unity Engine features that your Project doesn’t use. This setting is only available with the IL2CPP scripting backend.

Most apps don’t use every available DLL. This option strips out DLLs that your app doesn’t use to reduce the size of the built Player. If your app is using one or more classes that would normally be stripped out under your current settings, Unity displays a debug message when you try to build the app.
Managed Stripping Level 未使用のマネージ (C#) コードを Unity がどの程度積極的に除去するかを選択します。提供されているオプションは、MinimalLowMediumHigh です。
アプリケーションのビルド時に、Unity リンカーの処理によって、プロジェクトの使用するマネージ DLL から、使用されていないコードを取り除くことができます。コードを取り除くと、実行ファイルのサイズが大幅に小さくなりますが、使用されているコードが誤って削除されることがあります。

これらのオプションと、IL2CPP によるバイトコードストリッピングに関する詳細は、ManagedStrippingLevel を参照してください。
Vertex Compression チャンネルごとの頂点圧縮を設定します。これはプロジェクト内の全てのメッシュに影響します。
通常は、Vertex Compression は、メモリ上のメッシュデータのサイズを縮小して、ファイルサイズを縮小し、GPU パフォーマンスを向上させるために使用されます。

頂点圧縮の設定方法と、この設定の制限に関する詳細は、メッシュデータの圧縮 を参照してください。
Optimize Mesh Data Enable this option to strip unused vertex attributes from the mesh used in a build. This option reduces the amount of data in the mesh, which can help reduce build size, loading times, and runtime memory usage.

Warning: If you have this setting enabled, you should remember to not change material or shader settings at runtime.

Refer to PlayerSettings.stripUnusedMeshComponents for more information.
Texture MipMap Stripping 全てのプラットフォームでミップマップストリッピングを有効にします。これにより、ビルド時に、使用されていないミップマップがテクスチャから取り除かれます。Unity は、ミップマップの値を現在のプラットフォームの Quality Settings と比較することによって、使用されていないミップマップを特定します。ミップマップの値が現在のプラットフォームの全ての Quality Setting から除外されている場合は、Unity は、ビルド時にそれらのミップマップをビルドから削除します。QualitySettings.masterTextureLimit に、取り除かれたミップマップ値が設定されている場合、Unity は、取り除かれていない最も近いミップマップ値をそこに設定します。

Stack Trace

Select the logging settings for the WebGL platform.

WebGL プラットフォームの Logging 設定
WebGL プラットフォームの Logging 設定
  • Select your preferred stack trace method by enabling the option that corresponds to each Log Type (Error, Assert, Warning, Log, and Exception) based on the type of logging you require. For example:
    • ScriptOnly: Logs only when running scripts.
    • Full: Logs all the time.
    • None: No logs are ever recorded.

See stack trace logging for more information.

Legacy

Enable the Clamp BlendShapes (Deprecated) option to clamp the range of blend shape weights in Skinned Mesh Renderers.

WebGL プラットフォームの Legacy 設定
WebGL プラットフォームの Legacy 設定

Publishing settings

Use the Publishing Settings to configure how Unity builds your WebGL app. For example, you can choose to enable the browser cache to store its files in your build.

WebGL プラットフォームの Publishing 設定
WebGL プラットフォームの Publishing 設定
設定 機能
Enable Exceptions 実行時の予期しないコードの動作 (通常はエラーとみなされる) を処理する方法を選択します。選択肢は NoneExplicitly Throw Exceptions OnlyFull Without StacktraceFull With Stacktrace です。詳細は、WebGL プロジェクトのビルドと実行 を参照してください。
Compression Format Choose the compression format to use for release build files. The options are: Gzip, Brotli, or Disabled (none). Note that this option doesn’t affect development builds.
Name Files As Hashes これを有効にすると、ビルドの各ファイルのファイル名として非圧縮ファイルコンテンツの MD5 ハッシュを使用できます。
Data caching これを有効にすると、自動的にコンテンツのアセットデータをユーザーマシン上にキャッシュします。そのため、(コンテンツが変更されない限り) その後の実行で再度ダウンロードする必用がありません。
Caching は、ブラウザーによって提供される IndexedDB API を使用して実装されます。ブラウザーによっては、あるサイズを超えるデータをキャッシュする時にユーザーの許可を求める、などの IndexedDB API 関連の制限を実装している場合があります。
Debug Symbols Enable this option to preserve debug symbols and perform demangling (displaying the original function names) of the stack trace when an error occurs. For release builds, all the debug information is stored in a separate file which is downloaded from the server on demand when an error occurs. Development builds always have demangling support embedded in the main module and therefore aren’t affected by this option.
Show Diagnostics Overlay Enable this option to display an overlay in WebGL builds that displays diagnostics information. It’s available for both Development and Release builds. For more information, see Show Diagnostics Overlay Player settings.
Decompression Fallback Include decompression fallback code for build files in the loader. Use this option if you are unable to configure server response headers according to the selected compression method.
Initial Memory Size The initial size of the WASM heap memory in megabytes (MB). By default, this is set to 32 MB. If Memory Growth Mode is set to None, then this is also the maximum size of WASM heap memory.
Memory Growth Mode Choose the growth mode for the WASM heap memory from the following options. The recommended option is Geometric.
None The WASM heap memory has a fixed size configured in Initial Memory Size.
Linear The WASM heap memory increases by a fixed amount configured by Linear Memory Growth Step.
Geometric The WASM heap memory increases relative to the current heap size depending on the factor configured in Geometric Memory Growth Step and Geometric Memory Growth Cap.
Maximum Memory Size The maximum size of the WASM heap memory in MB. By default, this is set to 2048 MB. This option is only available for the Memory Growth Mode Linear or Geometric.
Linear Memory Growth Step Advanced tuning option to control the WASM heap growth step in MB. By default, this is set to 16 MB. A growth step of 16MB indicates that the heap is increased by 16MB each time it needs to grow. Only available if Memory Growth Mode is set to Linear.
Geometric Memory Growth Step Advanced tuning option to control the WASM heap growth factor relative to the current heap size. By default, this is set to 0.2. A growth factor of 0.2 means that the size of the heap is increased by 0.2 * currentHeapSize each time the heap needs to grow. Only available if Memory Growth Mode is set to Geometric.
Geometric Memory Growth Cap Advanced tuning option to control the upper limit for a heap growth step in MB. By default, this is set to 96 MB. A growth cap of 96MB means that the size of the heap is increased by at most 96 MB. Only available if Memory Growth Mode is set to Geometric.

Show Diagnostic Overlay setting

To help optimize WebGL builds and diagnose potential problems, you can view diagnostics information (currently limited to memory usage) by enabling this setting. Once enabled, an icon appears on the build that displays an overlay with useful data about the build. It’s available for both Development and Release builds.

  1. To view the diagnostics information, enable the Show Diagnostics Overlay option in the Player settings window (File > Build Settings > Player Settings > Publishing Settings).

    On desktop, the Diagnostics icon appears on the footer of the WebGL canvas:

    Diagnostics button on the footer of the canvas
    Diagnostics button on the footer of the canvas

    On a mobile device, the Diagnostics icon appears on the bottom-right of the screen:

    An Android phone displaying the diagnostics button
    An Android phone displaying the diagnostics button
  2. Click the Diagnostics icon. An overlay appears showing the JavaScript memory, which is further broken down to display WASM heap memory usage:

The Diagnostics overlay shows the Javascript memory distribution and the WASM heap memory usage
The Diagnostics overlay shows the Javascript memory distribution and the WASM heap memory usage

The following diagnostics appear on the overlay screen:

プロパティ 機能
Total JS (JavaScript) Memory The current size of the JS heap, including unused memory not allocated to any JS objects, in megabytes.
Used JS Memory Memory in use by JS objects, in megabytes.
Total WASM heap memory MLinear memory representing the entire heap of the C/C++ Unity engine that’s compiled with Emscripten, including unallocated memory, in megabytes.
Used WASM heapy The space of the WASM heap that’s allocated, in megabytes.

Important note about JS Memory

The JS Memory information is obtained using the performance.memory API, which is currently only supported on Chrome or Edge. There are no other APIs available that return this information for Safari or Firefox.

Note: This API isn’t supported on iOS devices.

On browsers where this API isn’t supported, a message showing N/A appears.

A N/A message appears on browsers that dont support performance.memory API
A N/A message appears on browsers that don’t support performance.memory API

その他の参考資料


  • WASM memory options were added in Unity 2022.1.
  • Show Diagnostics Overlay added in Unity 2022.2.

PlayerSettingsWebGL

高度な概要
WebGL のテクスチャ圧縮