I am trying to change material rendered on a cube upon click. Simple if else condition (I believe). I have tried
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Click");
if (GetComponent<Renderer>().material == brick)
{
Debug.Log("Brick");
GetComponent<Renderer>().material = normal;
}
else if(GetComponent<Renderer>().material == normal)
{
Debug.Log("Normal");
GetComponent<Renderer>().material = brick;
}
}
}
I am getting in the first loop ie GetMouseButtonDown. But Nothing happens to the cube after that. no errors or warnings.
Aucun commentaire:
Enregistrer un commentaire