You can prevent shader variantsA verion of a shader program that Unity generates according to a specific combination of shader keywords and their status. A Shader object can contain multiple shader variants. More info
See in Glossary from being compiled. This is called stripping. Stripping unneeded variants can greatly reduce build times, file size, shaderA program that runs on the GPU. More info
See in Glossary loading times, and runtime memory usage. In larger projects, or projects with complex shaders, this is a very important consideration.
The way that you declare shader keywords can limit the number of variants that they produce:
shader_feature
instead of multi_compile
where possible.multi_compile
.For information on doing this in hand-coded shaders, see Declaring and using shader keywords in HLSL. For information on doing this in Shader Graph, see Shader Graph: Blackboard.
There are several places in the Unity Editor UI(User Interface) Allows a user to interact with your application. More info
See in Glossary where you can configure shader stripping:
For shader variants that you can’t strip in other ways, you can use the following APIs in an Editor script to perform build-time stripping:
For more information on this subject, see the Unity blog post Stripping scriptable shader variants