title: How do I define a custom preprocessor macro in my shader?
body: <p>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:</p>
  <pre><code>#if defined(IS_UNITY_EDITOR)
      // something
  #else
      // other thing
  #endif
  </code></pre>
  <p>To achieve this, I'm trying <a href="https://docs.unity3d.com/ScriptReference/Shader.EnableKeyword.html" rel="nofollow noreferrer">the <code>Shader.EnableKeyword()</code> method</a> in a MonoBehavior:</p>
  <pre><code>if (Application.isEditor) {
      Shader.EnableKeyword(&quot;IS_UNITY_EDITOR&quot;);
  }
  </code></pre>
  <p>However, it looks like my shader is being compiled <em>before</em> the MonoBehavior can check if it's in the unity editor. I've tried running it on <code>Start()</code>, on <code>Awake()</code>, <code>OnEnable()</code> but the shader never receives the <code>IS_UNITY_EDITOR</code> definition. How can I define <code>IS_UNITY_EDITOR</code> in my shader before the shader is compiled?</p>