Dynamically setting a boolean property on a material using a Shader Graph generated shader

Hi !

I have created a shader using the shader graph that is based on the standard shader and extends it to make an object look selected and / or hovered based on two properties of type boolean.

The manual says that boolean properties are treated as floats. Thus, when I want to set one of these boolean properties, I naturally use Material.setFloat(). However, this does not seem to work.

My boolean properties are nammed “Hovered” and “Selected”. I tried with and without prefixing them with an underscore, but got the same result.

So my question is : am I using the right way to set those boolean properties ?

Also another tiny question : is there a way to combine the use of the shader graph and GPU instancing ?

Thanks !!

EDIT : I tried with an integer property and Material.setInt(), but still no change.

Well I found the solution. One has to use the property names generated by Unity. See : Setting unitys new shader graphs properties via C# - Questions & Answers - Unity Discussions

You have to use the reference name, which the Blackboard auto generates when you create a property, but which you can override if you want it called something else.

1 Like

Thanks for your help, as usual. :slight_smile: