WebGL
WebGL での開発を始めるにあたって

Player settings for the WebGL platform

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

WebGL Player settings
WebGL Player settings

以下のセクションでプロパティーのドキュメントを参照できます。

Note: Although the Icon panel appears on the WebGL Player window, there are no icon settings because WebGL games don’t use icons. Also, the only settings on the Splash Image panel are the common Splash Screen settings.

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

Resolution and Presentation

This section allows you to customize the size and style.

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

解像度

設定 機能
Default Canvas Width Set the width of the WebGL canvas element.
Default Canvas Height Set the width of the WebGL canvas element.
Run In Background Enable this option to allow your content to continue to run when the canvas or the browser window loses focus.

WebGL Template

Select a template to use for your WebGL Project:

  • The Default page is a simple white page with a loading bar on a grey canvas.
  • The Minimal page has only the necessary boilerplate code to run the WebGL content.

You can specify your own template so that you can run your game in a similar environment to the finished game. Follow the instructions in Using WebGL Templates.

Other Settings

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

Rendering

Use these settings to customize how Unity renders your game for the WebGL platform.

Rendering Player settings for the WebGL platform
Rendering Player settings for the WebGL platform
プロパティー 機能
Color Space Choose which color space should be used for rendering: Gamma or Linear.
See the 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 is not supported.
Static Batching Enable this option to use Static batching.
Dynamic Batching Enable this option to use Dynamic Batching on your build (enabled by default).
Note: Dynamic batching has no effect when a Scriptable Render Pipeline is active, so this setting is only visible when nothing is set in the Scriptable Render Pipeline Asset Graphics setting.
Graphics Jobs (Experimental) Enable this option to instruct Unity to offload graphics tasks (render loops) to worker threads running on other CPU cores. This is intended 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 instability.
Unity currently only supports Graphics Jobs when using Vulkan and this setting has no effect when using OpenGL ES.
Lightmap Streaming Enabled このオプションを有効にすると、現在のゲームカメラをレンダリングするために、必要に応じてライトマップのミップマップのみを読み込みます。この値は、生成されるライトマップテクスチャに適用されます。
ノート この設定を使用するには、Texture Streaming Quality 設定を有効にする必要があります。
Streaming Priority ライトマップのミップマップストリーミングの優先順位を設定して、リソースの競合を解決します。これらの値は、ライトマップテクスチャが生成されると用されます。
正の数値が優先されます。有効な値の範囲は –128 から 127 です。

Configuration

Configuration settings for the WebGL platform
Configuration settings for the WebGL platform
設定 機能
Scripting Runtime Version Choose which .NET implementation to use in your project. For more details, see Microsoft’s .NET documentation.
.NET 3.5 Equivalent (Deprecated) .NET 3.5 API を実装する .NET ランタイム。この機能は非推奨なので、使用しないでください。.NET 4 を使用してください。
.NET 4.x Equivalent .NET 4 API を実装する .NET ランタイム。この API は .NET 3.5 よりも新しい API で、より多くの API へのアクセスを提供し、より多くの外部ライブラリと互換性があり、C# 6 をサポートします。これはデフォルトのスクリプティングランタイムです。
Scripting Backend This option is not available for WebGL because WebGL always uses the IL2CPP Scripting backend.
API Compatibility Level Choose which .NET APIs you can use in your Project. This setting can affect compatibility with 3rd-party libraries.
Tip: If you are having problems with a third-party assembly, you can try the suggestion in the API Compatibility Level section below.
.Net 2.0 Maximum .net compatibility, biggest file sizes. Part of the deprecated .NET 3.5 runtime.
.Net 2.0 Subset Subset of full .net compatibility, smaller file sizes. Part of the deprecated .NET 3.5 runtime.
.Net Standard 2.0 Compatible with .NET Standard 2.0. Produces smaller builds and has full cross-platform support.
.Net 4.x Choose this option when using libraries that access APIs not included in .NET Standard 2.0. This option is compatible with the .NET Framework 4, which includes everything in the .NET Standard 2.0 profile as well as additional APIs.
Produces larger builds and any additional APIs available are not necessarily supported on all platforms. See Referencing additional class library assemblies for more information.
Disable HW Statistics Enable this option to instruct the application not to send information about the hardware to Unity. By default, Unity Android applications send anonymous HW statistics to Unity. This provides you with aggregated information to help you make decisions as a developer.
Scripting Define Symbols カスタムコンパイルフラグを設定します。詳細は、プラットフォーム依存コンパイル を参照してください。
Allow ‘unsafe’ Code 事前に定義されたアセンブリ (例えば Assembly-CSharp.dll) の ‘unsafe’ C# code をコンパイルするサポートを有効にします。
アセンブリ定義ファイル (.asmdef) の場合、.asmdef ファイルの 1 つをクリックし、表示された インスペクターウィンドウでオプションを有効にします。
Active Input Handling ユーザーからの入力をどのように処理するかを選択します。
Input Manager Use the traditional Input window.
Input System (Preview) 新しい Input (入力) システムを使用します。入力システムは開発中です。Input System のプレビュー版を使用するには、InputSystem パッケージ をインストールします。そのパッケージをインストールせずに Input System (Preview) オプションを選択すると、余分な処理が発生するだけで何も起こりません。
Both 両方のシステムを同時に使用できます。

API Compatibility Level

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

  1. Install Reflector for Windows.
  2. Drag the .NET assemblies for the API compatilibity level you are having issues with into Reflector. You can find these under Frameworks/Mono/lib/mono/YOURSUBSET/.
  3. Drag in your 3rd-party assembly.
  4. Right-click your 3rd-party assembly and select Analyze.
  5. In the analysis report, inspect the Depends on section. The report highlights anything that the 3rd-party assembly depends on, but that is not available in the .NET compatibility level of your choice in red.

Optimization

Optimization settings for the WebGL platform
Optimization settings for the WebGL platform
設定 機能
Prebake Collision Meshes ビルド時に衝突データをメッシュに加えるには、このオプションを有効にします。
Keep Loaded Shaders Alive シェーダーがアンロードされないようにするには、このオプションを有効にします。
Preloaded Assets 起動時にプレイヤーが読み込むためのアセットの配列を設定します。
新しいアセットを加えるには、Size プロパティーの値を増やし、表示される新しい Element ボックスに読み込むようにアセットへの参照を設定します。
Strip Engine Code コードのストリッピングを有効にします。この設定は IL2CPP Scripting Backend でのみ可能です。
たいていのゲームはすべての必要な dll を使用しているわけではありません。 Strip Engine Code を有効にすると、使用しない部分を取り除き、 iOS デバイスでビルドされたプレイヤーのサイズを削減します。現在選択しているオプションによって通常は削除されるはずのクラスをゲームで使用している場合は、ビルドするときにデバッグメッセージが表示されます。
Managed Stripping Level Choose how aggressively Unity strips unused managed (C#) code.
When Unity builds your game or application, the Unity Linker process can strip unused code from the managed dynamically linked libraries used in the project. Stripping code can make the resulting executable significantly smaller, but can sometimes mistakenly remove code that is actually used.
Normal ビルドサイズと .NET/IL2CPP のビルド時間を減らすために、アクセス不能なマネージコードを削除します。
Aggressive Remove code more aggressively than under the normal option. Code size is further reduced, but this additional reduction may have side effects. For example, some methods may no longer be visible in the debugger and code accessed through reflection can be stripped. You can create a custom link.xml file to preserve specific classes and methods. See Managed bytecode stripping with IL2CPP for more information
Vertex Compression Select which vertex channels should be compressed. For example, you can enable compression for everything except positions and lightmap UVs.
Compression can save memory and bandwidth but lowers precision. Whole Mesh compression set per imported object overrides where vertex compression is set on objects. Everything else obeys these vertex compression settings.
Optimize Mesh Data このオプションを有効にすると、メッシュに適用されるマテリアルに必要のないすべてのデータはメッシュから削除されます。

Logging

特定のコンテキストで許可するログのタイプを選択します。

Logging settings for the WebGL platform
Logging settings for the WebGL platform

スクリプト実行中にログを行う (ScriptOnly)、常に行なう (Full)、決して行なわない (None) のそれぞれに対して、ログのタイプ (ErrorAssertWarningLogException) にチェックを入れます。

Legacy

Clamp BlendShapes (Deprecated) オプションを有効にすると、SkinnedMeshRenderers でブレンドシェイプのウェイトの範囲を固定できます。

Legacy settings for the WebGL platform
Legacy settings for the WebGL platform

パブリッシングの設定

Publishing settings for the WebGL platform
Publishing settings for the WebGL platform
設定 機能
Memory Size Set the memory available to the WebGL runtime, given in megabytes. You should choose this value carefully: if it is too low, you will get out-of-memory errors because your loaded content and scenes won’t fit into the available memory. However, if you request too much memory then some browser/platform combinations might not be able to provide it and consequently fail to load the player. See Memory in WebGL for details.
Enable Exceptions Choose how to handle unexpected code behavior (generally considered errors) at run time. The options are: None, Explicitly Thrown Exceptions Only, Full Without Stacktrace, and Full With Stacktrace. See the Building and running a WebGL project page for details.
Compression Format Choose the compression format to use for release build files. The options are: Gzip, Brotli, or Disabled (none). Note that this option does not affect development builds.
Name Files As Hashes Enable this option to use an MD5 hash of the uncompressed file contents as a filename for each file in the build.
Data caching Enable this option to automatically cache your contents Asset data on the user’s machine so it doesn’t have to be re-downloaded on subsequent runs (unless the contents have changed).
Caching is implemented using the IndexedDB API provided by the browser. Some browsers may implement restrictions around this, such as asking the user for permission to cache data over a specific size.
Debug Symbols Enable this option to preserve debug symbols and perform demangling 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 are not affected by this option.
Linker Target Choose the build type to generate: asm.js, WebAssembly, or Both.
asm.js is widely supported across browsers, while WebAssembly is a new and efficient format for the web. If you choose Both, Unity generates both WebAssembly and asm.js formats. Then at run time, WebAssembly is used if it’s supported by the browser; otherwise it falls back to asm.js.

WebGL
WebGL での開発を始めるにあたって