- Home /
Question by
vasupandey777 · Jun 15, 2020 at 09:33 AM ·
uibuttonshop
How can I write a script to decrease points on pressing button only once and if i use the button again it will only change the color of the material and would not decrease any more money?
public GameObject buttonOn;
public GameObject buttonOff;
public int mcount;
void Start()
{
mcount = PlayerPrefs.GetInt("count");
if (mcount < 50)
{
buttonOff.GetComponent<Button>().interactable = false;
}
}
public void changeButton200()
{
if (mcount >= 50)
{
mcount = mcount - 50;
PlayerPrefs.SetInt("count", mcount);
buttonOff.SetActive(false);
buttonOn.SetActive(true);
}
}
public void changeColor1()
{
PlayerPrefs.SetInt("bmat",1);
}
public void changeColor3()
{
PlayerPrefs.SetInt("bmat",2);
}
}
Comment