Shaders - hiding property in inspector

So I have a somewhat unique problem. I have some really awkward shaders that I’m using for a very specific purpose, and one of the things they require is a “dummy texture”. Essentially, this is a texture that exists, but doesn’t need to be set. The purpose of this is to trick part of Unity’s rendering system, so I can use it as a work around to achieve what I need. Now, what I’d really like to do is keep this dummy texture completely under the hood. That is, hide it in the inspector. I noted that some of the terrain shaders had some properties marked with [HideInInspector], but this didn’t seem to work. I then had a look at custom material editors. While these will work, I have quite a few different shaders using this, so I’d rather not have to right a custom editor for each one, just to ignore one property. I did wonder if there was a way to exclude the property from the default inspector drawing through a custom editor, since that way I could use the same one for all the shaders, but I couldn’t find anything. I also considered dynamically searching through a list of the shader properties, but I don’t seem to be able to do this, either. Can anyone help me do this, or is my only solution to write an editor for each shader?

Put “[HideInInspector]” behind your property and it won’t show up in the inspector. I use this for script-driven shields in my game where I want to be able to set the alpha from script but don’t want me or my artists worrying about the alpha.

Properties {
	_FillColor ("Main Color", COLOR) = (1, 1, 1, 0)
	_RimColor ("Rim Color", Color) = (0.26, 0.19, 0.16, 0.0)
	[HideInInspector]_Alpha ("Alpha", Range(0.0, 1.0)) = 1.0
}

You’ll be able to se _FillColor and _RimColor in the inspector, but _Alpha doesn’t show up.

40415-capture.jpg

After a bit of digging into Unity’s documentation, I found the source code for Unity’s default MaterialEditor. From there, I found I could use ShaderUtils to grab a list of all properties, and have it exclude one the parts I wanted it to.