Is there a Unity feature to create Editor only shader variants?

I’m making a shader with custom GUI and want to provide debug options to artists. For example a toggle button to pipe vertex color directly out to pixels. But I want the shader/material exported in a bundle to ignore all the debug options.

I know how to create variants with #pragma shader_feature, I want to know if there’s a built in #define or feature to achieve this before I roll my own.

TNKS!

G

Unfortunately no.

There is a #pragma shader_feature EDITOR_VISUALIZATION that exists on the meta pass (which is enabled when you change the Scene view from Shaded to something else). It’s plausible Unity will automatically skip this for non-editor builds, but I don’t know for sure.

I would suggest you have a single “Debug” toggle that enables that, and then have any features you want to enable be toggled with branching (ie: using if (_MyDebug == 1) // return something ) rather than using lots of keywords. In editor you don’t really need to be concerned about absolute performance, but you should care about shader compile time and variants can increase that greatly.

1 Like