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 could 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 GraphBlackboard
property named Power
, and write code that can be used to set this value to zero or five in order to turn the glow effect on and off. We'll also access the Color
property so that we're able to 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 the link from the
Out (3)
output from the Multiply node to theEmission ...