Quantcast
Channel: Questions in topic: "hlsl"
Viewing all articles
Browse latest Browse all 206

When can I use Shader.EnableKeyword()?

$
0
0
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?

Viewing all articles
Browse latest Browse all 206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>