Increase the number just when the button is pressed
I make the alphabets select screen and i want to detect just those alphabets those are selected by user but i also have the unselect button feature so i want the functionality that if user press the button number count increase but when i again press the button to unselect the count number not increase. Here is my Select Button functionality : public bool defaultColor = true; Color32 transparentColor = new Color32(255, 255, 225, 150); Color32 originalColor = new Color32(255, 255, 225, 250);
public GameObject image;
public void TransparencyChange()
{
if (defaultColor == true)
{
image.GetComponent<Image>().color = transparentColor;
defaultColor = false;
}
else if (defaultColor != true)
{
image.GetComponent<Image>().color = originalColor;
defaultColor = true;
}
}
And Here is the Increase count number functionality which is attached to on click event of button: 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;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613053842im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Highscore system unity C# 0 Answers
Setting up a attack button 0 Answers
Score counted multiple times when several projectiles impact the same target 1 Answer
I have no Idea why my highscore Script isn't working ... 0 Answers
Cyclist script bug? 0 Answers