Shader forge Toggle

Hey guys i was wandering if anyone knew how to access the toggle or bool of a shader that was created in shader forge.

C Sharp
fireBaseObj.renderer.material.??(“_crafted”, true);

The material properties does at least have a GetInt and SetInt that you can expose as 0, 1 and convert to/use as a bool.

Unity - Scripting API: Material.GetInt (see GetFloat)

So in the properties of the shader something like

Properties {
    Crafted ("_Crafted", Range (0, 1)) = 0;
}

and then something like

bool myBool = (renderer.material.GetInt("_Crafted") == 1 ? true : false)

and

renderer.material.SetInt("_Crafted", 1);

(someone might have to correct my code, I haven’t actually tried this myself)

[Toggle(keyword)]name(“display name”,float)=number

Toggle node is just nice UI wrapper for Float value. If you want to change its value from script, simply use SetFloat function.

material.SetFloat(“_ParamName”, 0);