Use the following recommended Graphics settings to optimize your builds for the Unity Web platform.
Unused shaders can increase build times, file size, and memory usage. In most projects, use the Recommended option for most projects for each setting to strip your build of unused shaders and resources.
To reduce your build size further, use the Recommended option for the smallest build. Use these settings only if your project doesn’t use the related feature, because they strip the shader variants and resources that the feature needs.
Find these settings under Edit > Project Settings > Graphics. For more information on each setting, refer to the details in Graphics.
| Setting | Recommended option for most projects | Recommended option for the smallest build |
|---|---|---|
| Lightmap Modes | Automatic | Custom, then deselect all the checkboxes |
| Fog Modes | Automatic | Custom, then deselect all the checkboxes |
| Instancing Variants | Strip Unused | Strip All |
| Batch Renderer Group Variants | Strip if Entities Graphics Package is not installed | Strip All |
| Video | Include if referenced | Don’t Include |
| Always Included Shaders | Remove unused shaders. You can also edit this list using C#. | Empty the list |
For more ways to reduce build size, such as removing unused packages and built-in modules, refer to Remove unused resources from your Web build.
To change the Always Included Shaders list with a script, create a list of shaders you want in the list and assign it like this:
GraphicsSettings.alwaysIncludedShaders = newShadersList.ToArray();
If your project uses the Universal Render Pipeline (URP), use the following recommended settings to reduce the size of your Web build. Find these settings in the Graphics settings, URP assets, and Universal Renderer assets.
URP includes resources in your build based on the features you enable. Disable or strip a feature only if your project doesn’t use it, otherwise your build might not have the resources it needs. Check the settings in every URP asset your build uses, and in every Universal Renderer asset that those URP assets reference.
In Edit > Project Settings > Graphics, configure the following settings.
| Setting | Recommended option |
|---|---|
| Additional Shader Stripping Settings > Strip Runtime Debug Shaders | Enabled |
| Additional Shader Stripping Settings > Strip Unused Post Processing Variants And Resources | Enabled |
| Additional Shader Stripping Settings > Strip Unused Variants | Enabled |
| Additional Shader Stripping Settings > Strip Screen Coord Override Variants | Enabled |
| Terrain Shader Inclusion Settings > Include Terrain Shaders | Disabled |
When you strip shader variants, Unity might remove variants that your built project needs. Test your build to make sure it renders correctly. To check how many shader variants your project has, refer to Check how many shader variants you have. For more information, refer to Strip shader variants in URP.
In each URP asset your build uses, configure the following setting.
| Setting | Recommended option |
|---|---|
| GPU Resident Drawer | Disabled. For more information, refer to GPU Resident Drawer. |
In each Universal Renderer asset that your URP assets reference, configure the following settings.
| Setting | Recommended option |
|---|---|
| Post-processing | Disabled. For more information, refer to Post-processing in URP. |
| Renderer Features | Keep only the ones you use. For more information, refer to Renderer Features in URP. |