文档

Unity Engine


User Manual

Script Reference

Unity Engine


Check how many shader variants your build has in URP

Log how many shader variants Unity compiles and strips.
阅读时间2 分钟最后更新于 9 天前

Use logging to check how many shader variants Unity compiles if you use the Universal Render Pipeline (URP).
注意
For more methods you can use to check how many shader variants you have, refer to Check how many shader variants you have.
To log how many variants Unity compiles and strips in total in URP, follow these steps:
  1. Open the Graphics settings window.
  2. Open the URP tab.
  3. In the Additional Shader Stripping Settings section, select a Shader Variant Log Level other than Disabled.
  4. From the main menu, select File > Build Profiles.
  5. Enable
    Development Build

    ?

    .
  6. Build your project.
Unity logs the shader variant information to the following locations:
  • The Console window
  • The
    Editor.log
    log file. Search for the section that begins with
    Shader Stripping
    . For the location of
    Editor.log
    , refer to log files.
For each shader, Unity uses the format
Total=<Number of variants in build>/<Total number of variants>(<Percentage in build>)
. For example, the following log indicates that Unity kept 8 of the 39 variants of the Lit shader, including 1 of the 6 vertex shader variants of the
ForwardLit
shader pass:
Universal Render Pipeline/Lit - Total=8/39(20.51%)- ForwardLit (ScriptableRenderPipeline) (SubShader: 0) (ShaderType: Vertex) - Total=1/6(16.67%) - Time=0.0691ms...
To export the information in JSON format, follow these steps:
  1. In the Graphics settings window, open the URP tab.
  2. In the Additional Shader Stripping Settings section, enable Export Shader Variants.
  3. Build your project.
  4. In your project folder, open the
    Temp/graphics-settings-stripping.json
    and
    Temp/shader-stripping.json
    files.

Additional resources