How to change a materials bool in c#?

There is SetFloat, SetVector, but where is SetBool?

Also, what about Int2, 3, and 4?
Here is a substance with Int2, but I’m not sure how to change with script.

And last question, would float 3 in a substance be a Vector3, or int[3]?

There is no SetBool. Boolean values in shaders are integers of either value 0 (false) or 1 (true). So material.SetInt( “_KeepRatio”, 1 ) would set the “Keep ratio” toggle to true. :slight_smile:

13 Likes

Ahh ok thanks, I thought it might be something like that. As for Int2, how would I change brickcount x?

You’re welcome!
As for Int2 I have no clue to be honest so I must leave it for someone else to answer. .__.’

No worries haha. You don’t by chance know how to change substance Input Parameters by script, or can you?

Nope. The most advanced I’ve done regarding shaders is “toggles”, needless to say I’m far from beeing good at it.
I did a quick search on google though, could this help? https://docs.unity3d.com/ScriptReference/ProceduralMaterial.html

Haha yeah actually. I was just reading that and came to post my findings. Thanks again.
I don’t know why I couldn’t find it earlier, looked here and then was looking on SD forums.

1 Like

For anyone recently searching for this. I found this issue as well where i downloaded an effects shader and was trying to change certain values and while the floats and textures updated, the bools did not. Firstly, the bools were Floats and not ints (which i thought was weird) but secondly the bools labelled “Toggle” with a (“string”) afterward apparently require the “EnableKeyword()” and “DisableKeyword()” to toggle them and the “keyword” is the string in the parentheses after “Toggle”. (I think there’s also a method to print all the keyword, or you can view them in debug mode). Even when i changed the float value between 0 and 1, it wasn’t until i used the Enable/Disable Keyword method that I was able to see any change.

4 Likes

Would’ve never figure out by myself, thanks a lot