Newbie Question I guess but here goes:
GOAL:
Part 1: If a switch is activated switch Material 1 (Black) to Material 2 (White) and vice versa.
Part 2: Make sure this works for all objects the script is attached to.
So far it works for exactly 1 object in the scene e.g. Part 1 works, Part 2 doesn’t.
I’ve the feeling I’m missing the obvious answer but after trying my luck for 3? hours I give up.
Anyway here’s the code snippet.
{
public Material BlackMat;
public Material WhiteMat;
public Material PermanentMat;
public static bool switchActivated= false;
private string Material;
void Update () {
Material = renderer.materials[0].name;
if (switchActivated == true && Material == "White (Instance)")
{
renderer.material = BlackMat;
switchActivated = false;
}
else if (switchActivated== true && Material == "Black (Instance)")
{
renderer.material = WhiteMat;
switchActivated = false;
}
}
}