Hello, I’m trying to find a specific material on an object and its children and alter its colors based off of sliders. This is the code I have so far but it doesn’t work. Thank you for your help.
public void ChangeColor(float rvalue, float gvalue, float bvalue)
{
//Color materialcolor = new Color(rvalue,gvalue,bvalue,1);
materialcolor.r = rvalue;
materialcolor.g = gvalue;
materialcolor.b = bvalue;
foreach(Renderer part in r)
{
allmaterials = part.renderer.sharedMaterials;
//materiallength = Renderer.sharedMaterials.Length;
//allmaterials.Length;
materiallength = part.renderer.sharedMaterials.Length;
for (int i = 0; i < materiallength; i++)
{
if (allmaterials*.ToString() == "malenude-skin")*
{
allmaterials*.color = materialcolor;*
}
}
}
}
Format that code please. I can't read it.
– farooqaaaChanged. Sorry about that...
– kmccmk9Why have you commented
– farooqaaamaterialcolor?It didn't work but I didn't want to forget the code so I just commented it out until I could figure out how to make it work.
– kmccmk9Where is the
– farooqaaarvariable declared?