increase decrease score on multiples button click problem
i want to increase the score by 1 when i click button and the transparency of image change and want to decrease the score by 1 when i again click button and transparency change to default. Here is my code of button transparency change: public class ButtonInteractable : MonoBehaviour { public GameObject image;
public void TransparencyButton()
{
if (image.GetComponent<Image>().color == new Color32(255, 255, 255, 255))
{
image.GetComponent<Image>().color = new Color32(255, 255, 255, 150);
}
else if (image.GetComponent<Image>().color == new Color32(255, 255, 255, 150))
{
image.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
}
}
}
And here is my score script which is added on buttons on click event:
private Text count; private int countAmount;
public void Start()
{
countAmount = 0;
count = GetComponent<Text>();
}
// Update is called once per frame
void Update()
{
count.text = countAmount.ToString();
}
public void AddScore()
{
countAmount += 1;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613054046im_/https://answers.unity.com/themes/thub/images/avi.jpg)