How to pass KeywordEnum property to cginc file

I have declared this on my shader file properties block:

[KeywordEnum(None, SinWave)] _Animation ("Animation", Float) = 0.0

Now I want to pass this property to a cginc file that’s included by my shader file, so that I can:

#pragma multi_compile _ANIMATION_NONE, _ANIMATION_SINWAVE

But it seems they don’t work like:

uniform float _Animation;

Where value is past to the included cginc file.

What should I do to pass them along? Do I have to declare them in the main file?

As a side note, I could use Enum property to pass value to cginc. And by using step() function, I can somehow workaround this problem. But I still think it’s best to not compile/run code that’s not necessary?

Try with out the comma.

#pragma multi_compile OPTION_ONE OPTION_TWO

The documentation example for KeywordEnum and the multi_compile line there is the only time I’ve ever seen a comma used on that line, and I suspect it’s a typo.

2 Likes