- Home /
How to change RGB base of material via scripting (Normal map + base RGB) ?
Hello guys,
Here's my issue : I created a material composed of a normal map and an image (base RGB), I would like to change the base (RGB) via scripting. My aim is to be able to choose between several textures and apply different colors to a gameobject.
If anyone could help that would be a lot of help :D, thanks !
capture.jpg
(22.9 kB)
Comment
transform.renderer.material.color = Color.blue;
//if you have muliple color atributes in the shader you call them specifically
Thanks a lot mate ! Could I do the same for a picture ins$$anonymous$$d of a color ? :D
Best Answer
Answer by Namey5 · Apr 21, 2017 at 08:26 AM
public Texture2D tex;
...
GetComponent<Renderer>().material.SetTexture ("_MainTex", tex);
"_MainTex" might be different depending on what they have named the property in the shader, although that is the common naming method for the primary albedo.