This page details the Player settings specific to the WebGLA JavaScript API that renders 2D and 3D graphics in a web browser. The Unity WebGL build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info
See in Glossary platform. For a description of the general Player settings, see Player settings.
You can find documentation for the properties in the following sections:
Note: Although the Icon panel appears on the WebGL Player settings, there are no icon settings because WebGL games do not use icons.
For more information about WebGL Publishing Settings, see WebGL Building and Running.
This section allows you to customize the screen mode and default size.
Setting | Function |
---|---|
Default Canvas Width | Set the width of the WebGL canvas element. |
Default Canvas Height | Set the height 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. |
Select a template to use for your WebGL Project:
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.
Use the Virtual Reality Splash Image setting to select a custom splash image for XRAn umbrella term encompassing Virtual Reality (VR), Augmented Reality (AR) and Mixed Reality (MR) applications. Devices supporting these forms of interactive applications can be referred to as XR devices. More info
See in Glossary displays. For information on common Splash Screen settings, see Splash Screen.
This section allows you to customize a range of options organized into the following groups:
Use these settings to customize how Unity renders your game for the WebGL platform.
Property | Description | |
---|---|---|
Color Space | Choose which color space Unity uses for rendering: Gamma or Linear. For more information, see Linear rendering overview. Gamma: Gamma color space is typically used for calculating lighting on older hardware restricted to 8 bits per channel for the frame buffer format. Even though monitors today are digital, they might still take a gamma-encoded signal as input. Linear: Linear color space rendering gives more precise results. When you select to work in linear color space, the Editor defaults to using sRGB sampling. If your Textures are in linear color space, you need to work in linear color space and disable sRGB sampling for each Texture. |
|
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 | Uses Static batching. For more information, see Draw call batching. |
|
Dynamic Batching | Uses dynamic batching (enabled by default). For more information, see Draw call batching. Note: Dynamic batching has no effect when a Scriptable Render Pipeline is active, so this setting is only visible if the Scriptable Render Pipeline Asset Graphics setting is blank. |
|
Graphics Jobs | Offloads graphics tasks (render loops) to worker threads running on other CPU cores. This option reduces the time spent in Camera.Render on the main thread, which can be a bottleneck. |
|
Lightmap Encoding | Defines the encoding scheme and compression format of the lightmaps. You can choose from Low Quality, Normal Quality, or High Quality. |
|
Lightmap Streaming | Uses Mipmap Streaming for lightmaps. Unity applies this setting to all lightmaps when it generates them. Note: To use this setting, you must enable the Texture Streaming Quality setting. |
|
Streaming Priority | Sets 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 | Allows Unity to gather CPU/GPU frame timing statistics. Use this option with the Dynamic ResolutionA Camera setting that allows you to dynamically scale individual render targets, to reduce workload on the GPU. More info See in Glossary camera setting to determine if your application is CPU or GPU bound. |
|
Virtual Texturing | Enable this option to reduce GPU memory usage and texture loading times if your Scene contains many high resolution textures. For more information, see 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. For more information, see Shader data types and precision. | |
360 Stereo Capture | Allows Unity to 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. This keyword is not triggered outside the Stereo RenderCubemap function. For more information, see Stereo 360 Image and Video Capture. |
Setting | Description | |
---|---|---|
Scripting BackendA framework that powers scripting in Unity. Unity supports three different scripting backends depending on target platform: Mono, .NET and IL2CPP. Universal Windows Platform, however, supports only two: .NET and IL2CPP. More info See in Glossary |
This option isn’t available for WebGL because WebGL uses the IL2CPP Scripting backend by default. | |
API Compatibility Level | Choose which .NET APIs you can use in your project. This setting can affect compatibility with 3rd-party libraries. However, it has no effect on Editor-specific code (code in an Editor directory, or within an Editor-specific Assembly Definition). Tip: If you are having problems with a third-party assembly, you can try the suggestion in the API Compatibility Level section below. |
|
.Net Standard | Compatible with .NET Standard 2.0. Produces smaller builds and has full cross-platform support. | |
.Net Framework | Compatible with the .NET Framework 4 (which includes everything in the .NET Standard 2.0 profile as well as additional APIs). Choose this option when usng libraries that access APIs not included in .NET Standard 2.0. Produces larger builds and any additional APIs available are not necessarily supported on all platforms. See Referencing additional class library assemblies for more information. | |
C++ Compiler Configuration | Choose the C++ compiler configuration used when compiling IL2CPP generated code. Note: This property is disabled unless Scripting Backend is set to IL2CPP. |
|
Use incremental GC | Enable this to use the incremental garbage collector, which spreads garbage collection over several frames to reduce gc-related spikes in frame duration. | |
Assembly Version Validation | Enable this to run assembly version validation checks for signed assemblies. Leave this option unchecked to disable the Assembly Version. | |
Active Input Handling | Choose how you want to handle input from users. | |
Input Manager (old) | Use the default Input window. | |
Input System (Preview) | Use the newer Input system. The Input System is provided as a preview packageA preview package is in development and not yet ready for production. A package in preview might be at any stage of development, from the initial stages to near completion. See in Glossary for this release. To try a preview of the Input System, install the InputSystem package. |
|
Both | Use both systems side by side. |
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:
Frameworks/Mono/lib/mono/YOURSUBSET/
.Setting | Function | |
---|---|---|
Scripting Define Symbols | Set custom compilation flags. For more details, see the documentation on Platform dependent compilation. | |
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 | Disable this setting to display the C# warnings CS0169 and CS0649. | |
Allow ‘unsafe’ Code | Enable support for compiling ‘unsafe’ C# code in a pre-defined assembly (for example, Assembly-CSharp.dll ). For Assembly Definition Files ( .asmdef ), click on one of your .asmdef files and enable the option in the Inspector window that appears. |
|
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 are compiled. For more information, see Microsoft’s deterministic compiler option documentation. |
|
Enable Roslyn Analyzers | Disable this setting to compile user-written scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info See in Glossary without Roslyn analyzer DLLs that might be present in your project. |
|
Use Roslyn Reference Assemblies | Disable this setting to the compiler not to skip compilation reference assemblies when the metadata of the assembly does not change. |
Setting | Function | |
---|---|---|
Prebake CollisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info See in Glossary Meshes |
Enable this option to add collision data to Meshes at build time. | |
Keep Loaded Shaders Alive | When enabled, you cannot unload a shader. See Shader Loading for more information. | |
Preloaded Assets | Set an array of Assets for the player to load on startup. To add new Assets, increase the value of the Size property, then set a reference to the Asset to load in the new Element box that appears. |
|
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 | Choose how Unity strips unused managed (C#) code.The options are Disabled Low, Medium, and High. When Unity builds your app, the Unity Linker process can strip unused code from the managed DLLs your Project uses. Stripping code can make the resulting executable significantly smaller, but can sometimes accidentally remove code that is in use. For more information about these options, see documentation on Managed code stripping. For information about bytecode stripping with IL2CPP, see documentation on Managed bytecode stripping with IL2CPP. |
|
Script Call Optimization | Choose how to optionally disable exception handling for a speed boost at run time. For more information, see iOS Optimization. | |
Slow and Safe | Use full exception handling (with some performance impact on the device when using the Mono scripting backend). | |
Fast but no Exceptions | No data provided for exceptions on the device (the app runs faster when using the Mono scripting backend). Note: Using this option with the IL2CPP scripting backend doesn’t impact performance, but it might help avoid undefined behavior on release builds. |
|
Vertex Compression | Choose the channel that you want to set for compressing meshes under the vertex compressionA method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression. See in Glossary method, which by default, is set to Mixed. This affects all the meshes in your project. Typically, Vertex Compression is used to reduce the size of meshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info See in Glossary data in memory, reduce file size, and improve GPU performance. For information on how to configure vertex compression and limitations of this setting, see [compressing meshes]. |
|
Optimize Mesh Data | Selecting this option enables stripping of unused vertex attributes from the mesh used in a build. This reduces the amount of data in the mesh, which might help reduce build size, loading times, and runtime memory usage. However, you must remember to not change material or shader settings at runtime, if you have this setting enabled. See PlayerSettings.stripUnusedMeshComponents for more information. |
|
Texture MipMap Stripping | Enable this option to enable mipmap stripping for all platforms, which strips unused mipmaps from Textures at build time. Unity determines unused mipmaps by comparing the value of the mipmap against the Quality Settings for the current platform. If a mipmap value is excluded from every Quality Setting for the current platform, then Unity strips those mipmaps from the build at build time. If QualitySettings.masterTextureLimit is set to a mipmap value that has been stripped, Unity will set the value to the closest mipmap value that has not been stripped. |
Note: When specifying ShadersA program that runs on the GPU. More info
See in Glossary, if you used the Always Included Shaders list, Unity counts it as if all shader variants are needed even if your SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary does not require them. You might want to use Shader variant collections instead with the exact list of variants you need in the build to prevent excess memory usage for storing shaders.
Select what type of logging to allow in specific contexts.
See stack trace logging for more information.
Enable the Clamp BlendShapes (Deprecated) option to clamp the range of blend shape weights in Skinned Mesh Renderers.
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.
Setting | Function |
---|---|
Enable Exceptions | Choose how to handle unexpected code behavior 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. |
WebAssembly Arithmetic Exceptions | Enable this to activate arithmetic exceptions in code. For example, when rounding off a large float value to an integer. However, Unity recommends setting this to Ignore to prevent WebGL build issues. |
Compression Format | Choose the compression format to use for release build files. The options are: Gzip, Brotli, or Disabled (none). This option doesn’t affect development buildsA development build includes debug symbols and enables the Profiler. More info See in Glossary. |
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 (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. |
Decompression Fallback | Include decompression fallback code for build files in the loader. Use this option if you aren’t able to configure server response headers according to the selected compression method. |