This works but doesnāt utilize the DisableKeyword() that Iād like to learn how to use.
More importantly, for some reason this doesnāt update in the editor until I click play and again wont update until I unclick play. its very annoying and Iām hoping that using DisableKeyword() can fix this.
Lastly here are other things Iāve tried that DO NOT work. These are examples I found to do on other posts, etc.
if defined in combination with EnableKeyword() and DisableKeyword(). Shader acts as if never defined
material.EnableKeyword() will add the keyword to the shader list but wonāt remove the other keyword. In order to do that you must use material.DisableKeyword()
Hello there!
Iām having a similar problem, using EnableKeyword and DisableKeyword doesnt really update my game windows.
It only seems to work in Scene view. To make it work in Game view I need to actually stop and re-run the game (similar to what you said before).
Did you manage to make it work properly?
Thanks!
Hi. sorry for the late reply.
I did manage to make it work properly but I donāt know completely why. I made a custom inspector for my post process effect. That seemed to make the game view update immediately. Iām attaching the package so that you can view it if youād like.
This means that for your above example, you should be able to do something like:
// Can define two shader variants like this
#pragma multi_compile __ COMPOSITE_ON
// instead of this (the composite_off keyword doesn't need to be defined)
// #pragma multi_compile COMPOSITE_ON COMPOSITE_OFF
Hereās a quick example with āRED_TINT_ONā
Calling mat.EnableKeyword(āRED_TINT_ONā) should turn on the red tint, and mat.DisableKeyword(āRED_TINT_ONā) should turn it off.