Custom Material Inspectors enable you to define how Unity displays properties in the Material Inspector for a particular shader. This is useful if a shader includes a lot of properties and you want to organize them in the Inspector. The Universal Render Pipeline (URP) and High Definition Render Pipeline (HDRP) both support custom Material Inspectors, but the method to create them is slightly different.
The implementation for custom Material Inspectors differs between URP and HDRP. For example, for compatibility purposes, every custom Material Inspector in HDRP must inherit from HDShaderGUI
which does not exist in URP. For information on how to create custom Material Inspectors for the respective render pipelines, see:
When you create a shader, either hand-written or using Shader Graph, both URP and HDRP provide a default editor for it to use. To override this default and provide your own custom Material Inspector, the method differs depending on whether you hand-wrote the shader or used Shader Graph.
To set a custom Material Inspector for a hand-written shader:
This is the same method as for the Built-in Renderer’s custom shader GUI.
For an example of how to do this, see the following shader code sample. In this example, the name of the custom Material Inspector class is ExampleCustomMaterialInspector:
Shader "Custom/Example"
{
Properties
{
// Shader properties
}
SubShader
{
// Shader code
}
CustomEditor "ExampleCustomMaterialInspector"
}
To set a custom Material Inspector for a Shader Graph shader: