Toggling a Shader Graph color glow effect through C# code
Effects such as the glow effect from the previous recipe are often features we wish to toggle on and off under different circumstances. The effect can be turned on or off during a game to visually communicate the status of a GameObject – for example, an angry character might glow red, while a happy monster might glow green, and so on.
We’ll add to the previous recipe to create a new publicly exposed Shader Graph blackboard property named Power
. Then, we’ll write some code that can be used to set this value to 0
or 5
in order to turn the glow effect on and off. We’ll also access the Color property so that we can set what color the glow effect displays.
Getting ready
This recipe builds on the previous one, so make a copy of that project and use the copy for this recipe.
How to do it...
To toggle the glow effect from the Shader Graph, follow these steps:
- First, delete...