Turning on and off parameters of a shaders

I have a fairly complex shader I’m developing and it’s getting to a place where I can see that all of these parameters will not be useful all of the time. I’d like to learn how to set some of these optional parameters as hidden.

For example, I have a baseColor, a blendColor, and an optional blendMask.

How could I “toggle” the blendMask option so that if I didn’t check “Mask Blend”, the blendMask texture slot wouldn’t even appear?

One way is to add a script that controls the editor for a shader. It does add some work to your shader development, but you end up with a nicer GUI experience when working with the shader.

The script would extend from ShaderGUI and will have to draw the whole editor GUI for the shader in OnGUI. Then in the shader you tell Unity it has a custom editor using:

CustomEditor "YourEditorClass"

The custom editor for the standard shader comes with the builtin shader package.

As far as I know there is no easy way to do this from the shader itself. All you can really do is permanently hide some properties.

1 Like