I’m trying to use a preprocessor macro in my custom shader so it performs a different step if it’s in the Unity Editor:
#if defined(IS_UNITY_EDITOR)
// something
#else
// other thing
#endif
To achieve this, I’m using the Shader.EnableKeyword
method in a MonoBehavior:
if (Application.isEditor) {
Shader.EnableKeyword("IS_UNITY_EDITOR");
}
However, my shader is being compiled before the monobehavior can check if it’s in the unity editor. I’ve tried running it on Start()
and on Awake()
, but the shader never receives the IS_UNITY_EDITOR
definition. How can I enable that keyword before the shader is compiled?