Change Shaders Seetings in Script ( Double Sided )

Hi,
I’m looking at how to change the flag of the “Two sided” in my script.
by default it is deactivate when I add it to an object. So I need that my script change the value to true after adding it to the object :

Renderer rend = Object3D.GetComponent<Renderer>();
rend.material.shader = Shader.Find("Particles/Standard Surface");


Thanks for any help.

I’m not sure what shader that is off hand, built-in or custom, but normally a toggle like that would be set with Material.SetInt() with a value of 1 for on or 0 for off. If that’s a built-in shader though, it’s possible that’s a custom inspector and the values are more complicated. I’d recommend loading the proper material, instead of a shader, with the correct values already set.

thx, I’ll look for that. and i’ll keep it posted.

so i tried to use this shader :

but the thing is, I use the property of the particule shader to add the color of the mesh to the texture to differentiate when the object is selected of when he is not.

so I’m a bit at loss here. my build-in shader have the option Two Sided, and in the editor I can change it, I juste need the name to access it an modiffy in runtime. I don’t have any custome or add-on. I’m new to Unity. So it’s weard for me that I can’t have acces to un toggle in runtime when I see it in the editor.

It’s DONE ! I’ve finally found it ! it was the Cull of the shader that I needed to put to “off” but it’s a float so you need to put it at 0 :

Renderer rend = MyObject.GetComponent<Renderer>();
rend.material.SetFloat("_Cull", 0);

So much time for one line X_X .
well, thanj you and I hope this will help some one else too ^^ .

1 Like